// 点击后的详细页面管理
$(function () {
    echart_map();

    //echart_1 暂时没有作用
    function echart_1() {
        var myChart = echarts.init(document.getElementById('chart_1'));
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    //echart_2 红树林足迹图
    function echart_2() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_2'));
        var option;
        var symbolSize = 20;
        var data = [
            [15, 0], [-50, 10], [-20, 20], [-70, 30], [-40, 40], // 第一段蜿蜒
            [-30, 50], [-80, 56], [-10, 70], [-90, 80], [-20, 90], // 第二段蜿蜒
        ];
        option = {
            tooltip: {
                triggerOn: 'none',
                formatter: function (params) {
                    return 'X: ' + params.data[0].toFixed(2) + '<br>Y: ' + params.data[1].toFixed(2);
                }
            },
            grid: {
            },
            xAxis: {
                min: -130,
                max: 60,
                type: 'value',
                axisLine: {onZero: false},
                axisLabel: {
                    color: '#FFFFFF', // 设置x轴字体颜色为白色
                    fontSize: 14    // 设置x轴字体大小
                }
            },
            yAxis: {
                min: -10,
                max: 99,
                type: 'value',
                axisLine: {onZero: false},
                axisLabel: {
                    color: '#FFFFFF', // 设置x轴字体颜色为白色
                    fontSize: 14    // 设置x轴字体大小
                }
            },
            dataZoom: [
                {
                    type: 'slider',
                    xAxisIndex: 0,
                    filterMode: 'empty'
                },
                {
                    type: 'slider',
                    yAxisIndex: 0,
                    filterMode: 'empty'
                },
                {
                    type: 'inside',
                    xAxisIndex: 0,
                    filterMode: 'empty'
                },
                {
                    type: 'inside',
                    yAxisIndex: 0,
                    filterMode: 'empty'
                }
            ],
            series: [
                {
                    id: 'a',
                    type: 'line',
                    smooth: true,
                    symbolSize: symbolSize,
                    data: data
                }
            ]
        };

        myChart.setOption(option);


        setTimeout(function () {
            myChart.setOption({
                graphic: echarts.util.map(data, function (item, dataIndex) {
                    return {
                        type: 'circle',
                        position: myChart.convertToPixel('grid', item),
                        shape: {
                            cx: 0,
                            cy: 0,
                            r: symbolSize / 2
                        },
                        invisible: true,
                        draggable: true,
                        ondrag: echarts.util.curry(onPointDragging, dataIndex),
                        onmousemove: echarts.util.curry(showTooltip, dataIndex),
                        onmouseout: echarts.util.curry(hideTooltip, dataIndex),
                        z: 100
                    };
                })
            });
        }, 0);
        window.addEventListener('resize', updatePosition);
        myChart.on('dataZoom', updatePosition);
        function updatePosition() {
            myChart.setOption({
                graphic: echarts.util.map(data, function (item, dataIndex) {
                    return {
                        position: myChart.convertToPixel('grid', item)
                    };
                })
            });
        }
        function showTooltip(dataIndex) {
            myChart.dispatchAction({
                type: 'showTip',
                seriesIndex: 0,
                dataIndex: dataIndex
            });
        }
        function hideTooltip(dataIndex) {
            myChart.dispatchAction({
                type: 'hideTip'
            });
        }
        function onPointDragging(dataIndex, dx, dy) {
            data[dataIndex] = myChart.convertFromPixel('grid', this.position);

            // Update data
            myChart.setOption({
                series: [{
                    id: 'a',
                    data: data
                }]
            });
        }
    }
    function loadGeoJson() {
        var xhr = new XMLHttpRequest();
        //把 JSON 放到 Spring Boot 的 static 下，然后用 HTTP 打开 index.html(http://localhost:8088/index.html)
        xhr.open('GET', '/china.geo.json', false);
        xhr.send(null);
        if (xhr.status === 200) {
            return JSON.parse(xhr.responseText);
        } else {
            console.error('geoJson 加载失败');
            return null;
        }
    }
    // echart_map 城市红树林数量分布
    function echart_map() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_map'));
        geoJson = loadGeoJson();
        echarts.registerMap('china', geoJson);
        // 以下是模拟全国的红树林数据
        var geoCoordMap = {
            '安徽省': [117.17, 31.52],
            '北京市': [116.40, 39.90],
            '重庆市': [106.55, 29.57],
            '福建省': [119.30, 26.08],
            '甘肃省': [103.73, 36.03],
            '广东省': [113.16, 23.08],
            '广西壮族自治区': [108.33, 22.84],
            '贵州省': [106.63, 26.65],
            '海南省': [110.35, 20.02],
            '河北省': [114.52, 38.05],
            '黑龙江省': [126.63, 45.75],
            '河南省': [113.65, 34.76],
            '湖北省': [114.34, 30.55],
            '湖南省': [112.93, 28.23],
            '江苏省': [118.46, 32.03],
            '江西省': [115.89, 28.68],
            '吉林省': [125.32, 43.90],
            '辽宁省': [123.43, 41.80],
            '内蒙古自治区': [111.75, 40.84],
            '宁夏回族自治区': [106.27, 38.47],
            '青海省': [101.78, 36.62],
            '山东省': [117.00, 36.65],
            '山西省': [112.53, 37.87],
            '陕西省': [108.95, 34.27],
            '上海市': [121.47, 31.23],
            '四川省': [104.06, 30.67],
            '天津市': [117.19, 39.12],
            '西藏自治区': [91.13, 29.65],
            '新疆维吾尔自治区': [87.68, 43.77],
            '云南省': [102.71, 25.04],
            '浙江省': [120.15, 29.28],
            '台湾省': [121.50, 25.03]
        };
        var data = [
            {name: '安徽省', value: Math.round(Math.random() * 10000)},
            {name: '北京市', value: Math.round(Math.random() * 10000)},
            {name: '重庆市', value: Math.round(Math.random() * 10000)},
            {name: '福建省', value: Math.round(Math.random() * 12000)+23000},
            {name: '甘肃省', value: Math.round(Math.random() * 8000)},
            {name: '广东省', value: Math.round(Math.random() * 15000)+30000},
            {name: '广西壮族自治区', value: Math.round(Math.random() * 13000)},
            {name: '贵州省', value: Math.round(Math.random() * 8000)},
            {name: '海南省', value: Math.round(Math.random() * 14000)+20000},
            {name: '河北省', value: Math.round(Math.random() * 10000)},
            {name: '黑龙江省', value: Math.round(Math.random() * 7000)},
            {name: '河南省', value: Math.round(Math.random() * 10000)},
            {name: '湖北省', value: Math.round(Math.random() * 10000)},
            {name: '湖南省', value: Math.round(Math.random() * 10000)},
            {name: '江苏省', value: Math.round(Math.random() * 10000)},
            {name: '江西省', value: Math.round(Math.random() * 10000)},
            {name: '吉林省', value: Math.round(Math.random() * 7000)},
            {name: '辽宁省', value: Math.round(Math.random() * 10000)},
            {name: '内蒙古自治区', value: Math.round(Math.random() * 7000)},
            {name: '宁夏回族自治区', value: Math.round(Math.random() * 7000)},
            {name: '青海省', value: Math.round(Math.random() * 6000)},
            {name: '山东省', value: Math.round(Math.random() * 12000)},
            {name: '山西省', value: Math.round(Math.random() * 8000)},
            {name: '陕西省', value: Math.round(Math.random() * 9000)},
            {name: '上海市', value: Math.round(Math.random() * 11000)},
            {name: '四川省', value: Math.round(Math.random() * 10000)},
            {name: '天津市', value: Math.round(Math.random() * 10000)},
            {name: '西藏自治区', value: Math.round(Math.random() * 5000)},
            {name: '新疆维吾尔自治区', value: Math.round(Math.random() * 6000)},
            {name: '云南省', value: Math.round(Math.random() * 8000)},
            {name: '浙江省', value: Math.round(Math.random() * 12000)},
            {name: '台湾省', value: Math.round(Math.random() * 10000)+20000}
        ];
        var max = 40000, min = 10; // todo
        var maxSize4Pin = 100, minSize4Pin = 20;
        var convertData = function (data) {
            var res = [];
            for (var i = 0; i < data.length; i++) {
                var geoCoord = geoCoordMap[data[i].name];
                if (geoCoord) {
                    res.push({
                        name: data[i].name,
                        value: geoCoord.concat(data[i].value)
                    });
                }
            }
            return res;
        };
        var option5 = {
            tooltip: {
                trigger: 'item',
                formatter: function(params) {
                    if (typeof(params.value)[2] == "undefined") {
                        return params.name + ' : ' + params.value;
                    } else {
                        return params.name + ' : ' + params.value[2];
                    }
                }
            },
            visualMap: {
                show: true,
                min: 0,
                max: max,
                right: '3%',
                top: 'bottom',
                text: ['高', '低'],
                calculable: true,
                color: ['#d94e5d','#eac736','#50a3ba'],
                textStyle: {
                    color: '#fff'
                }
            },
            geo: {
                map: 'china',
                show: true,
                roam: true,
                label: {
                    normal: {
                        show: true,
                        textStyle: {
                            color: '#d94e5d'
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        areaColor: '#ffd2a0',
                        borderColor: '#404a59'
                    },
                    emphasis: {
                        areaColor: '#d94e5d'
                    }
                }
            },
            series: [
                {
                    name: '数据点',
                    type: 'scatter',
                    coordinateSystem: 'geo',
                    data: convertData(data),
                    symbolSize: function(val) {
                        return val[2] / 1000;
                    },
                    label: {
                        normal: {
                            formatter: '{b}',
                            position: 'right',
                            show: true
                        },
                        emphasis: {
                            show: true
                        }
                    },
                    itemStyle: {
                        normal: {
                            color: '#d94e5d'
                        }
                    }
                },
                {
                    type: 'map',
                    map: 'china',
                    geoIndex: 0,
                    aspectScale: 0.75,  // 长宽比
                    showLegendSymbol: false, // 存在legend时显示
                    label: {
                        normal: {
                            show: false
                        },
                        emphasis: {
                            show: false,
                            textStyle: {
                                color: '#fff'
                            }
                        }
                    },
                    roam: true,
                    itemStyle: {
                        normal: {
                            areaColor: '#ffd2a0',
                            borderColor: '#404a59'
                        },
                        emphasis: {
                            areaColor: '#d94e5d'
                        }
                    },
                    animation: false,
                    data: data
                }
            ]
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option5);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    //echart_3 风玫瑰（雷达图）
    function echart_3() {
        var myChart = echarts.init(document.getElementById('chart_3'));
        myChart.clear();
        var option106 = {
            color: ['#67F9D8', '#FFE434', '#56A3F1', '#FF917C'],
            legend: {
                orient: 'horizontal',
                top: '5%',
                left: '5%',
                textStyle: {
                    color: '#ffffff', // 图例文字颜色
                    fontSize: 16 // 图例文字大小
                }
            },
            radar: [
                {
                    indicator: [
                        { text: '树木覆盖率（%）', max: 100 },
                        { text: '碳储量（吨/公顷）', max: 50 },
                        { text: '生物多样性（物种数）', max: 200 },
                        { text: '水文调节能力（分）', max: 100 },
                        { text: '土壤稳定性（分）', max: 100 }
                    ],
                    center: ['25%', '50%'],
                    radius: 156, // 120 * 130%
                    startAngle: 90,
                    splitNumber: 4,
                    shape: 'circle',
                    axisName: {
                        color: '#ffffff', // 指标名称的颜色
                        fontSize: 16, // 指标名称的字体大小
                        formatter: '【{value}】',
                        color: '#428BD4'
                    },
                    splitArea: {
                        areaStyle: {
                            color: ['#77EADF', '#26C3BE', '#64AFE9', '#428BD4'],
                            shadowColor: 'rgba(0, 0, 0, 0.2)',
                            shadowBlur: 10
                        }
                    },
                    axisLine: {
                        lineStyle: {
                            color: 'rgba(211, 253, 250, 0.8)'
                        }
                    },
                    splitLine: {
                        lineStyle: {
                            color: 'rgba(211, 253, 250, 0.8)'
                        }
                    }
                },
                {
                    indicator: [
                        { text: '病虫害发生率（%）', max: 100 },
                        { text: '生态系统健康指数（分）', max: 100 },
                        { text: '光合活性（mol/m²/d）', max: 500 },
                        { text: '潮间带宽度（m）', max: 50 },
                        { text: '盐度变化（ppt）', max: 35 }
                    ],
                    center: ['75%', '50%'],
                    radius: 156, // 120 * 130%
                    axisName: {
                        color: '#fff',
                        backgroundColor: '#666',
                        borderRadius: 3,
                        padding: [3, 5]
                    }
                }
            ],
            series: [
                {
                    type: 'radar',
                    emphasis: {
                        lineStyle: {
                            width: 4
                        }
                    },
                    data: [
                        {
                            value: [80, 30, 150, 90, 80],
                            name: '当前状态',
                            areaStyle: {
                                color: 'rgba(67, 249, 216, 0.4)' // 调整颜色
                            }
                        }
                    ]
                },
                {
                    type: 'radar',
                    radarIndex: 1,
                    data: [
                        {
                            value: [50, 80, 300, 20, 15],
                            name: '环境变化',
                            symbol: 'rect',
                            symbolSize: 12,
                            lineStyle: {
                                type: 'dashed'
                            },
                            label: {
                                show: true,
                                formatter: function (params) {
                                    return params.value;
                                }
                            },
                            areaStyle: {
                                color: new echarts.graphic.RadialGradient(0.1, 0.6, 1, [
                                    {
                                        color: 'rgba(255, 145, 124, 0.1)',
                                        offset: 0
                                    },
                                    {
                                        color: 'rgba(255, 145, 124, 0.9)',
                                        offset: 1
                                    }
                                ])
                            }
                        }
                    ]
                }
            ]
        };
        myChart.setOption(option106);
    }

    //echart_4 红树林在线实时监控（目前使用静态红树林图片作为效果演示）
    function echart_4() {
        var myChart = echarts.init(document.getElementById('chart_4'));

        var img = new Image();
        img.onload = function() {
            // 图片加载完成后再设置ECharts配置，确保图表初始化时图片已加载
            var option = {
                graphic: {
                    elements: [{
                        type: 'image',
                        style: {
                            image: img.src, // 直接使用已加载的图片路径
                            width: 750,
                            height: 500
                        },
                        left: 'center',
                        top: 'middle',
                        draggable: true,
                        onclick: function () {
                            console.log('Image clicked.');
                        }
                    }]
                }
            };

            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
            window.addEventListener("resize", function () {
                myChart.resize();
                option.graphic.elements[0].style.width = myChart.getWidth() * 0.8; // 动态调整图片宽度为容器宽度的80%
                option.graphic.elements[0].style.height = myChart.getHeight() * 0.8; // 动态调整图片高度为容器高度的80%
                myChart.setOption(option);
            });
        };
        img.src = '../img/Mangroves.png'; // 设置图片源路径
    }

    //echart_5 暂时没有作用
    function echart_5() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_5'));
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    //echart_6 红树林扩展模块一：物候相机
    function echart_6() {
        var myChart = echarts.init(document.getElementById('chart_6'));
        var imgs = {
            src: '../img/3330160_rgbnormal_PTZ000_2024_08_10_110028_533.jpeg',
            src1: '../img/3330160_rgbnormal_PTZ000_2024_08_12_110029_374.jpeg',
            src2: '../img/3330160_nirndvi_PTZ000_2024_08_11_130028_480.jpeg',
            src3: '../img/3330160_nirraw_PTZ000_2024_08_11_110028_342.jpeg'
        };
        var img = new Image();
        img.onload = function() {
            // 图片加载完成后再设置ECharts配置，确保图表初始化时图片已加载
            var option = {
                graphic: {
                    elements: [
                        {
                            type: 'image',
                            style: {
                                image: imgs.src,
                                width: 375,
                                height: 250
                            },
                            left: '17.5%',  // 左上角图片的位置
                            top: '14%',
                            draggable: true,
                            onclick: function () {
                                console.log('Image clicked.');
                            }
                        },
                        {
                            type: 'image',
                            style: {
                                image: imgs.src3,
                                width: 375,
                                height: 250
                            },
                            left: '53%',  // 右上角图片的位置
                            top: '14%',
                            draggable: true,
                            onclick: function () {
                                console.log('Image clicked.');
                            }
                        },
                        {
                            type: 'image',
                            style: {
                                image: imgs.src2,
                                width: 375,
                                height: 250
                            },
                            left: '17.5%',  // 左下角图片的位置
                            top: '50%',
                            draggable: true,
                            onclick: function () {
                                console.log('Image clicked.');
                            }
                        },
                        {
                            type: 'image',
                            style: {
                                image: imgs.src1,
                                width: 375,
                                height: 250
                            },
                            left: '53%',  // 右下角图片的位置
                            top: '50%',
                            draggable: true,
                            onclick: function () {
                                console.log('Image clicked.');
                            }
                        }
                    ]
                }
            };
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option);
            window.addEventListener("resize", function () {
                myChart.resize();
                // 根据窗口大小调整每张图片的大小
                option.graphic.elements.forEach(function(element) {
                    element.style.width = myChart.getWidth() * 0.35;  // 35% of container width
                    element.style.height = myChart.getHeight() * 0.35;  // 35% of container height
                });
                myChart.setOption(option);
            });
        };
        img.src = imgs.src;  // 确保至少加载一张图片以初始化图表
    }

    //echart_7  暂时没有作用
    function echart_7() {
        var myChart = echarts.init(document.getElementById('chart_7'));
        myChart.clear();
        option = {
            title: {
                text: ''
            },
        };
        myChart.setOption(option);
    }

    //echart_8  暂时没有作用
    function echart_8() {
        var myChart = echarts.init(document.getElementById('chart_8'));
        myChart.clear();
        option = {
            title: {
                text: ''
            },
        };
        myChart.setOption(option);
    }

    //echart_9  暂时没有作用
    function echart_9() {
        var myChart = echarts.init(document.getElementById('chart_9'));
        myChart.clear();
        option = {
            title: {
                text: ''
            },
        };
        myChart.setOption(option);
    }

    //echart_10 红树林扩展模块二：不同月份下的红树林指标热力图（可通过调整图例来选择性展示）
    function echart_10() {

        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_10'));

        // 更新为红树林生态监测数据
        var months = ['2023年2月', '2023年3月', '2023年4月', '2023年5月', '2023年6月', '2023年7月', '2023年8月', '2023年9月', '2023年10月', '2023年11月', '2023年12月', '2024年1月', '2024年2月', '2024年3月', '2024年4月', '2024年5月', '2024年6月', '2024年7月'];
        var monitoringTypes = ['气体交换率', '土壤水分含量', '光合有效辐射', '红树种群覆盖度', '水体溶解氧', '生态系统碳吸收率', '根际硝态氮浓度', '潮汐水位变化', '红树叶面积指数'];
        var data = [];
        var valueCounter = 0;

        for (var i = 0; i < months.length; i++) {
            for (var j = 0; j < monitoringTypes.length; j++) {
                data.push([i, j, Math.round(Math.random() * 300)]);
            }
        }

        data = data.map(function (item) {
            return [item[0], item[1], item[2] || '-'];
        });

        option = {
            tooltip: {
                position: 'top',
                formatter: function(params) {
                    var value = params.data[2];
                    return monitoringTypes[params.value[1]] + ' in ' + months[params.value[0]] + ': ' + value;
                }
            },
            grid: {
                left: '7%',
                right: '10%',
                bottom: '15%',
                top: '13%',
                containLabel: true
            },
            xAxis: {
                type: 'category',
                data: months,
                axisLine: {
                    lineStyle: {
                        color: '#fff'  // 轴线颜色
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#fff'  // 更改x轴字体颜色为白色
                    }
                },
                splitArea: {
                    show: true
                }
            },
            yAxis: {
                type: 'category',
                data: monitoringTypes,
                axisLine: {
                    lineStyle: {
                        color: '#fff'  // 轴线颜色
                    }
                },
                axisLabel: {
                    textStyle: {
                        color: '#fff'  // 更改x轴字体颜色为白色
                    }
                },
                splitArea: {
                    show: true
                }
            },
            visualMap: {
                min: 0,
                max: 300,
                calculable: true,
                orient: 'vertical', // 设置为垂直
                right: '2%', // 设置为右对齐，5%是距离右边的距离
                bottom: '10%',
                // inverse: true, // 反转滑动手柄方向
                textStyle: {
                    color: '#fff' // 设置文字颜色为白色
                }
            },
            series: [{
                name: '红树林生态监测',
                type: 'heatmap',
                data: data,
                label: {
                    show: true
                },
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }]
        };

        myChart.setOption(option);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }

    //echart_11 红树林扩展模块三：温度与盐分浓度折线图
    function echart_11() {
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('chart_11'));

        // 更新为红树林相关的数据，覆盖最近12个月
        var excelJson_11 = [
            {a: '2023年8月', b: '盐分浓度 (‰)', c: 32},
            {a: '2023年8月', b: '温度变化 (°C)', c: 32},
            {a: '2023年9月', b: '盐分浓度 (‰)', c: 33},
            {a: '2023年9月', b: '温度变化 (°C)', c: 30},
            {a: '2023年10月', b: '盐分浓度 (‰)', c: 34},
            {a: '2023年10月', b: '温度变化 (°C)', c: 27},
            {a: '2023年11月', b: '盐分浓度 (‰)', c: 33},
            {a: '2023年11月', b: '温度变化 (°C)', c: 25},
            {a: '2023年12月', b: '盐分浓度 (‰)', c: 32},
            {a: '2023年12月', b: '温度变化 (°C)', c: 26},
            {a: '2024年1月', b: '盐分浓度 (‰)', c: 31},
            {a: '2024年1月', b: '温度变化 (°C)', c: 25},
            {a: '2024年2月', b: '盐分浓度 (‰)', c: 30},
            {a: '2024年2月', b: '温度变化 (°C)', c: 26},
            {a: '2024年3月', b: '盐分浓度 (‰)', c: 29},
            {a: '2024年3月', b: '温度变化 (°C)', c: 25},
            {a: '2024年4月', b: '盐分浓度 (‰)', c: 28},
            {a: '2024年4月', b: '温度变化 (°C)', c: 27},
            {a: '2024年5月', b: '盐分浓度 (‰)', c: 27},
            {a: '2024年5月', b: '温度变化 (°C)', c: 29},
            {a: '2024年6月', b: '盐分浓度 (‰)', c: 26},
            {a: '2024年6月', b: '温度变化 (°C)', c: 30},
            {a: '2024年7月', b: '盐分浓度 (‰)', c: 25},
            {a: '2024年7月', b: '温度变化 (°C)', c: 33}
        ];

        var wei1 = [], wei2 = [];
        // 第一列：月份
        wei1.push(excelJson_11[0].a);
        for (var i = 1; i < excelJson_11.length; i++) {
            if (i > 0 && excelJson_11[i].a !== wei1[wei1.length - 1]) {
                wei1.push(excelJson_11[i].a);
            }
        }
        console.log(wei1);

        // 第二列：监测指标
        wei2.push(excelJson_11[0].b);
        for (var i = 1; i < excelJson_11.length; i++) {
            if (i > 0 && excelJson_11[i].b !== wei2[0]) {
                wei2.push(excelJson_11[i].b);
            } else {
                break;
            }
        }
        console.log(wei2);

        // 第二列的每个一列的值
        var value_2_1_11 = [];
        for (var x = 0; x < wei2.length; x++) {
            var value1 = [];
            var wei2index = wei2[x];
            for (var i = 0; i < excelJson_11.length; i++) {
                if (excelJson_11[i].b === wei2index) {
                    value1.push(excelJson_11[i].c);
                }
            }
            var item = {
                name: wei2index,
                value: value1
            };
            value_2_1_11.push(item);
        }
        console.log(value_2_1_11);

        var xData_11_ = wei1;
        var legendData_11 = wei2;

        // 第二列的每个一列的值 的图表配置
        var seriesData_11 = [];
        // 每一项的颜色配置
        var colorData_11 = ['rgb(253, 3, 62)', 'rgb(32, 15, 253)'];
        for (var i = 0; i < value_2_1_11.length; i++) {
            var item = {
                name: legendData_11[i],
                type: 'line',
                smooth: true,
                symbol: 'circle',
                symbolSize: 9,
                showSymbol: false,
                lineStyle: {
                    normal: {
                        color: colorData_11[i],
                        width: 3,
                        shadowColor: 'rgba(0,0,0,0.4)',
                        shadowBlur: 10,
                        shadowOffsetX: 4,
                        shadowOffsetY: 10
                    }
                },
                data: value_2_1_11[i].value
            };
            seriesData_11.push(item);
        }
        console.log(seriesData_11);

        var option11 = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    animation: false
                }
            },
            legend: {
                data: legendData_11,
                top: '10%',
                textStyle: {
                    color: '#fff'
                },
            },
            xAxis: [{
                type: 'category',
                boundaryGap: false,
                axisLine: {
                    onZero: true
                },
                axisLabel: {
                    textStyle: {
                        color: '#fff',
                    }
                },
                data: xData_11_
            }],
            yAxis: [{
                type: 'value',
                axisLabel: {
                    textStyle: {
                        color: '#fff',
                    }
                },
            }],
            series: seriesData_11
        };
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option11);
        window.addEventListener("resize", function () {
            myChart.resize();
        });
    }
    
    // 下面是重点：echart_12，植被物候，首先是全局变量和方法
    var currentType = 'average';  // 默认是平均值，可以是 'average', 'min', 'max'
    var currentStats = 'Default';
    let count = 1;
    var callCount = 0;  // 初始化调用次数计数器
    var alertTriggered = false;  // 初始化标记
    var timer;
    let isFirstSelect = true;

    function showAlertOnce(message) {
        if (!alertTriggered) {
            alert(message);
            alertTriggered = true;  // 设置标记为true

            // 重置标记，假设1秒后可以再次触发
            setTimeout(function() {
                alertTriggered = false;
            }, 1000);
        }
    }
    //植被物候！
    function echart_12() {

        var myChart = echarts.init(document.getElementById('chart_12'));
        myChart.clear();

        //Default模式下的数据初始化
        var data = [];
        var raw_ndvi = [];
        var averages_ndvi = [];
        var maxValues_ndvi = [];
        var minValues_ndvi = [];
        var raw_roi_ndvi = [];
        var averages_roi_ndvi = [];
        var maxValues_roi_ndvi = [];
        var minValues_roi_ndvi = [];
        var raw_gcc = [];
        var averages_gcc = [];
        var maxValues_gcc = [];
        var minValues_gcc = [];
        var raw_gvi = [];
        var averages_gvi = [];
        var maxValues_gvi = [];
        var minValues_gvi = [];
        var raw_rcc = [];
        var averages_rcc = [];
        var maxValues_rcc = [];
        var minValues_rcc = [];
        var raw_bcc = [];
        var averages_bcc = [];
        var maxValues_bcc = [];
        var minValues_bcc = [];
        var raw_low_lai = [];
        var averages_low_lai = [];
        var maxValues_low_lai = [];
        var minValues_low_lai = [];
        var raw_fvc = [];
        var averages_fvc = [];
        var maxValues_fvc = [];
        var minValues_fvc = [];

        for (var i = 0; i < processedData.length; i++) {
            var item = processedData[i];

            data.push(item.date);
            raw_ndvi.push(item.ndvi.values);
            averages_ndvi.push(item.ndvi.average);
            maxValues_ndvi.push(item.ndvi.max);
            minValues_ndvi.push(item.ndvi.min);
            raw_roi_ndvi.push(item.roiNdvi.values);
            averages_roi_ndvi.push(item.roiNdvi.average);
            maxValues_roi_ndvi.push(item.roiNdvi.max);
            minValues_roi_ndvi.push(item.roiNdvi.min);
            raw_gcc.push(item.gcc.values);
            averages_gcc.push(item.gcc.average);
            maxValues_gcc.push(item.gcc.max);
            minValues_gcc.push(item.gcc.min);
            raw_gvi.push(item.gvi.values);
            averages_gvi.push(item.gvi.average);
            maxValues_gvi.push(item.gvi.max);
            minValues_gvi.push(item.gvi.min);
            raw_rcc.push(item.rcc.values);
            averages_rcc.push(item.rcc.average);
            maxValues_rcc.push(item.rcc.max);
            minValues_rcc.push(item.rcc.min);
            raw_bcc.push(item.bcc.values);
            averages_bcc.push(item.bcc.average);
            maxValues_bcc.push(item.bcc.max);
            minValues_bcc.push(item.bcc.min);
            raw_low_lai.push(item.lowlai.values);
            averages_low_lai.push(item.lowlai.average);
            maxValues_low_lai.push(item.lowlai.max);
            minValues_low_lai.push(item.lowlai.min);
            raw_fvc.push(item.fvc.values);
            averages_fvc.push(item.fvc.average);
            maxValues_fvc.push(item.fvc.max);
            minValues_fvc.push(item.fvc.min);
        }

        //Hourly Stats模式下数据的初始化，更细粒度的时间划分
        var dataTime = [];
        var ndvi_time = [];
        var roi_ndvi_time = [];
        var gcc_time = [];
        var gvi_time = [];
        var rcc_time = [];
        var bcc_time = [];
        var low_lai_time = [];
        var fvc_time = [];

        for (var i = 0; i < processedDataTime.length; i++) {
            var item = processedDataTime[i];

            dataTime.push(item.time);

            ndvi_time.push(item.ndvi.average);
            roi_ndvi_time.push(item.roiNdvi.average);
            gcc_time.push(item.gcc.average);
            gvi_time.push(item.gvi.average);
            rcc_time.push(item.rcc.average);
            bcc_time.push(item.bcc.average);
            low_lai_time.push(item.lowlai.average);
            fvc_time.push(item.fvc.average);
        }

        // 给xData_109赋值，这一部分值得优化
        var xData_109 = function() {
            var data1 = data
            return data1;
        }();

        // 下面是时间选择框+将选择后的时间及时更新赋值（年月日都按照正确的算法计算，日期正确，有分是否是闰年）
        function populateYears(select) {
            if (select.options.length === 0) { // 只有当没有选项时才填充
                for (let i = 2020; i <= new Date().getFullYear(); i++) {
                    let option = new Option(i, i);
                    select.add(option);
                }
            }
        }
        function populateMonths(select) {
            if (select.options.length === 0) { // 只有当没有选项时才填充
                for (let i = 1; i <= 12; i++) {
                    let option = new Option(i, i);
                    select.add(option);
                }
            }
        }
        function populateDays(select, year, month) {
            let dayCount = new Date(year, month, 0).getDate();
            select.innerHTML = ''; // 清空之前的选项再添加新的选项
            for (let i = 1; i <= dayCount; i++) {
                let option = new Option(i, i);
                select.add(option);
            }
        }

        // 初始化年份、月份和日期选择器
        populateYears(document.getElementById('start-year'));
        populateYears(document.getElementById('end-year'));
        populateMonths(document.getElementById('start-month'));
        populateMonths(document.getElementById('end-month'));
        populateDays(document.getElementById('start-day'), new Date().getFullYear(), new Date().getMonth() + 1);
        populateDays(document.getElementById('end-day'), new Date().getFullYear(), new Date().getMonth() + 1);

        function updateDays() {
            const yearSelects = [document.getElementById('start-year'), document.getElementById('end-year')];
            const monthSelects = [document.getElementById('start-month'), document.getElementById('end-month')];
            const daySelects = [document.getElementById('start-day'), document.getElementById('end-day')];

            yearSelects.forEach((yearSelect, index) => {
                yearSelect.addEventListener('change', () => {
                    const year = yearSelect.value;
                    const month = monthSelects[index].value;
                    populateDays(daySelects[index], year, month);
                });
            });

            monthSelects.forEach((monthSelect, index) => {
                monthSelect.addEventListener('change', () => {
                    const year = yearSelects[index].value;
                    const month = monthSelect.value;
                    populateDays(daySelects[index], year, month);
                });
            });
        }

        updateDays();

        document.getElementById('update-button').addEventListener('click', function() {
            clearTimeout(timer); // 清除之前的计时器
            callCount++;  // 每次点击增加调用次数

            let startYear = document.getElementById('start-year').value;
            let startMonth = document.getElementById('start-month').value;
            let startDay = document.getElementById('start-day').value;
            let endYear = document.getElementById('end-year').value;
            let endMonth = document.getElementById('end-month').value;
            let endDay = document.getElementById('end-day').value;

            let startDate = `${startYear}-${startMonth.padStart(2, '0')}-${startDay.padStart(2, '0')}`;
            let endDate = `${endYear}-${endMonth.padStart(2, '0')}-${endDay.padStart(2, '0')}`;

            if (new Date(startDate) > new Date(endDate)) {
                showAlertOnce("开始日期不能晚于结束日期。");
                callCount = 0;  // 重置计数器
            } else {
                // 在这里添加更新图表或其他逻辑的代码
                console.log("选定的日期范围:", startDate, "至", endDate);

                var filteredDates = data.filter(date => date >= startDate && date <= endDate);

                console.log("fileredDates",filteredDates);
                console.log("callCount",callCount);

                // 仅在第三次点击时检查是否没有数据
                if (callCount >= 3 && filteredDates.length === 0) {
                    showAlertOnce("所选日期范围内没有数据。");
                    callCount = 0;  // 重置计数器
                    return;
                }

                // 重置计数器，如果1秒内没有新的点击
                timer = setTimeout(() => {
                    callCount = 0;
                }, 1);

                updateChart(filteredDates);
            }

        });

        //这部分为时间选择之后的updateChart()，用于选择特定时间段后的图表更新
        function updateChart(filteredDates) {
            xData_109 = filteredDates;

            // 执行初始化函数
            var data = [];
            var raw_ndvi = [];
            var averages_ndvi = [];
            var maxValues_ndvi = [];
            var minValues_ndvi = [];
            var raw_roi_ndvi = [];
            var averages_roi_ndvi = [];
            var maxValues_roi_ndvi = [];
            var minValues_roi_ndvi = [];
            var raw_gcc = [];
            var averages_gcc = [];
            var maxValues_gcc = [];
            var minValues_gcc = [];
            var raw_gvi = [];
            var averages_gvi = [];
            var maxValues_gvi = [];
            var minValues_gvi = [];
            var raw_rcc = [];
            var averages_rcc = [];
            var maxValues_rcc = [];
            var minValues_rcc = [];
            var raw_bcc = [];
            var averages_bcc = [];
            var maxValues_bcc = [];
            var minValues_bcc = [];
            var raw_low_lai = [];
            var averages_low_lai = [];
            var maxValues_low_lai = [];
            var minValues_low_lai = [];
            var raw_fvc = [];
            var averages_fvc = [];
            var maxValues_fvc = [];
            var minValues_fvc = [];

            for (var i = 0; i < processedData.length; i++) {
                var item = processedData[i];

                data.push(item.date);
                raw_ndvi.push(item.ndvi.values);
                averages_ndvi.push(item.ndvi.average);
                maxValues_ndvi.push(item.ndvi.max);
                minValues_ndvi.push(item.ndvi.min);
                raw_roi_ndvi.push(item.roiNdvi.values);
                averages_roi_ndvi.push(item.roiNdvi.average);
                maxValues_roi_ndvi.push(item.roiNdvi.max);
                minValues_roi_ndvi.push(item.roiNdvi.min);
                raw_gcc.push(item.gcc.values);
                averages_gcc.push(item.gcc.average);
                maxValues_gcc.push(item.gcc.max);
                minValues_gcc.push(item.gcc.min);
                raw_gvi.push(item.gvi.values);
                averages_gvi.push(item.gvi.average);
                maxValues_gvi.push(item.gvi.max);
                minValues_gvi.push(item.gvi.min);
                raw_rcc.push(item.rcc.values);
                averages_rcc.push(item.rcc.average);
                maxValues_rcc.push(item.rcc.max);
                minValues_rcc.push(item.rcc.min);
                raw_bcc.push(item.bcc.values);
                averages_bcc.push(item.bcc.average);
                maxValues_bcc.push(item.bcc.max);
                minValues_bcc.push(item.bcc.min);
                raw_low_lai.push(item.lowlai.values);
                averages_low_lai.push(item.lowlai.average);
                maxValues_low_lai.push(item.lowlai.max);
                minValues_low_lai.push(item.lowlai.min);
                raw_fvc.push(item.fvc.values);
                averages_fvc.push(item.fvc.average);
                maxValues_fvc.push(item.fvc.max);
                minValues_fvc.push(item.fvc.min);
            }

            // 计算标签显示间隔
            var labelInterval = Math.floor(xData_109.length / 5);
            var maxLabels = 5;
            var interval = Math.floor(xData_109.length / maxLabels);
            var labelIndexes = new Set();
            for (let i = 0; i < xData_109.length; i += interval) {
                labelIndexes.add(i);
            }
            //ROI
            var _data_109_1 = averages_ndvi;
            //ROI NDVI，以下内容按.csv顺序进行赋值
            var _data_109_2 = averages_roi_ndvi;
            var _data_109_3 = averages_gcc;
            var _data_109_4 = averages_gvi;
            var _data_109_5 = averages_rcc;
            var _data_109_6 = averages_bcc;
            var _data_109_7 = averages_low_lai;
            var _data_109_8 = averages_fvc;


            // 计算单个数据点标准差的函数，这里的values应该是每天的所有数据点数组
            function calculateStandardDeviation(values) {
                let dailySDs = [];
                // 假设values是一个二维数组，每个子数组代表一天的所有数据点
                values.forEach(dayValues => {
                    const mean = dayValues.reduce((a, b) => a + b, 0) / dayValues.length;
                    const sd = Math.sqrt(dayValues.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / dayValues.length);
                    dailySDs.push(sd);
                });
                return dailySDs;
            }

            var sd_1 = calculateStandardDeviation(raw_ndvi);
            var sd_2 = calculateStandardDeviation(raw_roi_ndvi);
            var sd_3 = calculateStandardDeviation(raw_gcc);
            var sd_4 = calculateStandardDeviation(raw_gvi);
            var sd_5 = calculateStandardDeviation(raw_rcc);
            var sd_6 = calculateStandardDeviation(raw_bcc);
            var sd_7 = calculateStandardDeviation(raw_low_lai);
            var sd_8 = calculateStandardDeviation(raw_fvc);

            // 把数值、标准差、索引都整合在一个数据结构errorData中，便于后续自定义样式
            var errorData_1 = _data_109_1.map((value, index) => ({
                value: value,
                //每天计算得到的标准差创建每个数据点的错误数据
                sd: sd_1[index],
                index: index
            }));
            var errorData_2 = _data_109_2.map((value, index) => ({
                value: value,
                sd: sd_2[index],
                index: index
            }));

            var errorData_3 = _data_109_3.map((value, index) => ({
                value: value,
                sd: sd_3[index],
                index: index
            }));
            var errorData_4 = _data_109_4.map((value, index) => ({
                value: value,
                sd: sd_4[index],
                index: index
            }));
            var errorData_5 = _data_109_5.map((value, index) => ({
                value: value,
                sd: sd_5[index],
                index: index
            }));
            var errorData_6 = _data_109_6.map((value, index) => ({
                value: value,
                sd: sd_6[index],
                index: index
            }));
            var errorData_7 = _data_109_7.map((value, index) => ({
                value: value,
                sd: sd_7[index],
                index: index
            }));
            var errorData_8 = _data_109_8.map((value, index) => ({
                value: value,
                sd: sd_8[index],
                index: index
            }));

            // 重点：自定义标准差样式。优化点：有很多重复的点，这一段写的非常冗余
            // 后续可以考虑将计算好的数据传入封装好的八种renderItem自定义样式中，可以减少很多代码
            function renderItem_1(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差


                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#CCFF66', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#CCFF66', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_2(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_3(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#498D4B', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#498D4B', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_4(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(186,85,211,1)',
                            lineDash: [5, 5],
                            lineWidth: 2
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_5(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#94070A', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#94070A', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_6(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_7(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#A47D1C', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#A47D1C', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_8(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#FF5D5D', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            option109 = {
                // backgroundColor: "#344b58",
                "title": {
                    "text": "",
                    "subtext": '',
                    x: "4%",

                    textStyle: {
                        color: '#fff',
                        fontSize: '22'
                    },
                    subtextStyle: {
                        color: '#90979c',
                        fontSize: '16',

                    },
                },
                "tooltip": {
                    "trigger": "axis",
                    "axisPointer": {
                        "type": "shadow",
                        textStyle: {
                            color: "#fff"
                        }
                    },
                    formatter: function(params) {
                        // console.log(params)
                        var indexX =0;
                        for(var x=0;x<xData_109.length;x++){
                            if(params[0].name === xData_109[x]){
                                indexX = x;
                                break;
                            }
                        }

                        var displayString = '监测时间：' + params[0].name
                        for(var m =0;m<params.length;m++){
                            var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' +  "(index, value, sd)" + params[m].data;
                            displayString = displayString + itemString
                        }
                        return displayString
                    }
                },
                "grid": {
                    "borderWidth": 0,
                    "top": 110,
                    "bottom": 95,
                    textStyle: {
                        color: "#fff"
                    }
                },
                legend: [{
                    right: '4%',
                    top: '3%',  // 主图例，包含所有的指标
                    textStyle: {
                        color: '#fff',
                        fontSize: '16',
                    },
                    data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                },
                    {
                        right: '4%',
                        top: '8%', // 统计指标图例，稍微往下
                        textStyle: {
                            color: '#fff',
                            fontSize: '16',
                        },
                        data: ["Average", "Max", "Min", "Hourly Stats"],
                        selected: {
                            "Average": true, // 默认选择平均值
                            "Max": false,
                            "Min": false,
                            "Hourly Stats": false
                        }
                    }],



                "calculable": true,
                "xAxis": [{
                    "type": "category",
                    "axisLine": {
                        lineStyle: {
                            color: '#90979c'
                        }
                    },
                    "splitLine": {
                        "show": false
                    },
                    "axisTick": {
                        "show": false
                    },
                    "splitArea": {
                        "show": false
                    },
                    "axisLabel": {
                        "interval": 0,
                        textStyle: {
                            color: '#fff',
                            fontSize: '16',
                        },
                        formatter: function (value, index) {
                            // 只显示特定的索引标签
                            return labelIndexes.has(index) ? value : '';
                        }
                    },
                    "data": xData_109,
                }],
                "yAxis": [{
                    "type": "value",
                    "splitLine": {
                        "show": false
                    },
                    "axisLine": {
                        lineStyle: {
                            color: '#90979c'
                        }
                    },
                    "axisTick": {
                        "show": false
                    },
                    "axisLabel": {
                        "interval": labelInterval,
                        textStyle: {
                            color: '#fff',
                            fontSize: '16',
                        },
                    },
                    "splitArea": {
                        "show": false
                    },

                }],
                "series": [

                    {
                        name: 'NDVI',
                        type: 'custom',
                        renderItem: renderItem_1,
                        data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 'index',
                            y: ['value','sd'],
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "#CCFF66",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'ROI NDVI',
                        type: 'custom',
                        renderItem: renderItem_2,
                        data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "rgba(0,191,183,1)",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'GCC',
                        type: 'custom',
                        renderItem: renderItem_3,
                        data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "#498D4B",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'GVI',
                        type: 'custom',
                        renderItem: renderItem_4,
                        data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "rgba(186,85,211,1)",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'RCC',
                        type: 'custom',
                        renderItem: renderItem_5,
                        data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "#94070A",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'BCC',
                        type: 'custom',
                        renderItem: renderItem_6,
                        data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "rgba(252,230,48,1)",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'LOW_LAI',
                        type: 'custom',
                        renderItem: renderItem_7,
                        data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "#A47D1C",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'FVC',
                        type: 'custom',
                        renderItem: renderItem_8,
                        data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                        encode: {
                            x: 0,
                            y: 1,
                            tooltip: [1]
                        },
                        "itemStyle": {
                            "normal": {
                                "color": "#FF5D5D",
                                "label": {
                                    "show": false,
                                    "textStyle": {
                                        "color": "#fff"
                                    },
                                    "position": "insideTop",
                                    formatter: function(p) {
                                        return p.value > 0 ? (p.value) : '';
                                    }
                                }
                            }
                        },
                    },
                    {
                        name: 'Average',
                        type: 'line'
                    },
                    {
                        name: 'Max',
                        type: 'line'
                    },
                    {
                        name: 'Min',
                        type: 'line'
                    },
                    {
                        name: 'Hourly Stats',
                        type: 'line'
                    }
                ]
            }

            myChart.setOption(option109);

            //监听函数，用于响应所有的legend图例，重点是Average、Max、Min和Hourly Stats
            myChart.on('legendselectchanged', function (params) {

                var selected = params.selected;

                var newData_ndvi;
                var newData_roi_ndvi;
                var newData_gcc;
                var newData_gvi;
                var newData_rcc;
                var newData_bcc;
                var newData_low_lai;
                var newData_fvc;


                // 更新currentType基于所选择的Legend
                var updateSelected = {
                    'Average': false,
                    'Max': false,
                    'Min': false,
                    'Hourly Stats': false
                };


                if(params.name=='Average'||params.name=='Max'||params.name=='Min'||params.name=='Hourly Stats'){
                    updateSelected[params.name] = true;  // 设置当前选中的图例为true，其他为false
                }

                //更细粒度的时间划分
                var dataTime = [];
                var ndvi_time = [];
                var roi_ndvi_time = [];
                var gcc_time = [];
                var gvi_time = [];
                var rcc_time = [];
                var bcc_time = [];
                var low_lai_time = [];
                var fvc_time = [];

                for (var i = 0; i < processedDataTime.length; i++) {
                    var item = processedDataTime[i];

                    if (filteredDates.includes(item.date)) { // 确保item.date是你数据中的日期字段
                        dataTime.push(item.time);

                        ndvi_time.push(item.ndvi.average);
                        roi_ndvi_time.push(item.roiNdvi.average);
                        gcc_time.push(item.gcc.average);
                        gvi_time.push(item.gvi.average);
                        rcc_time.push(item.rcc.average);
                        bcc_time.push(item.bcc.average);
                        low_lai_time.push(item.lowlai.average);
                        fvc_time.push(item.fvc.average);
                    }
                }

                function processHourlyStats(dataTime, valueTime) {
                    // 创建一个包含24个空数组的数组，每个数组对应一个小时
                    let hourlyData = Array.from({ length: 24 }, () => []);

                    // 遍历时间和值的数据，将值分配到正确的小时数组中
                    for (let i = 0; i < dataTime.length; i++) {
                        let time = dataTime[i];
                        let value = valueTime[i];
                        let hour = parseInt(time.split(':')[0]); // 直接从时间字符串"HH:MM:SS"中分割并取小时部分

                        console.log("time", time);
                        console.log("value", value);
                        console.log("hour", hour);

                        hourlyData[hour].push(value);
                    }

                    // 计算每个小时的统计数据
                    let hourlyStats = hourlyData.map(hour => {
                        if (hour.length === 0) return { average: null, max: null, min: null };

                        let sum = hour.reduce((acc, val) => acc + val, 0);
                        let average = sum / hour.length;
                        let max = Math.max(...hour);
                        let min = Math.min(...hour);

                        return { average, max, min };
                    });

                    return hourlyStats;
                }

                // 现在使用上面定义的函数来处理每个指标
                let hourlyStats_ndvi = processHourlyStats(dataTime, ndvi_time);
                let hourlyStats_roi_ndvi = processHourlyStats(dataTime, roi_ndvi_time);
                let hourlyStats_gcc = processHourlyStats(dataTime, gcc_time);
                let hourlyStats_gvi = processHourlyStats(dataTime, gvi_time);
                let hourlyStats_rcc = processHourlyStats(dataTime, rcc_time);
                let hourlyStats_bcc = processHourlyStats(dataTime, bcc_time);
                let hourlyStats_low_lai = processHourlyStats(dataTime, low_lai_time);
                let hourlyStats_fvc = processHourlyStats(dataTime, fvc_time);

                //根据选择图例的不同，进行不同情况下的赋值。同时注意，在选择Hourly Stats时要观察currentType，以便在某种状态下（如Average）的Default到Hourly Stats的无缝切换。
                if (params.name === 'Average') {
                    currentType = 'average';
                    newData_ndvi = averages_ndvi;
                    newData_roi_ndvi = averages_roi_ndvi;
                    newData_gcc = averages_gcc;
                    newData_gvi = averages_gvi;
                    newData_rcc = averages_rcc;
                    newData_bcc = averages_bcc;
                    newData_low_lai = averages_low_lai;
                    newData_fvc = averages_fvc;
                    updateSelected['Average'] = true;
                } else if (params.name === 'Max') {
                    currentType = 'max';
                    newData_ndvi = maxValues_ndvi;
                    newData_roi_ndvi = maxValues_roi_ndvi;
                    newData_gcc = maxValues_gcc;
                    newData_gvi = maxValues_gvi;
                    newData_rcc = maxValues_rcc;
                    newData_bcc = maxValues_bcc;
                    newData_low_lai = maxValues_low_lai;
                    newData_fvc = maxValues_fvc;
                    updateSelected['Max'] = true;
                } else if (params.name === 'Min') {
                    currentType = 'min';
                    newData_ndvi = minValues_ndvi;
                    newData_roi_ndvi= minValues_roi_ndvi;
                    newData_gcc = minValues_gcc;
                    newData_gvi = minValues_gvi;
                    newData_rcc = minValues_rcc;
                    newData_bcc = minValues_bcc;
                    newData_low_lai = minValues_low_lai;
                    newData_fvc = minValues_fvc;
                    updateSelected['Min'] = true;
                } else if (params.name === 'Hourly Stats') {
                    // 将每个指标的数据更新为按小时统计的数据
                    if (currentType == 'average') {
                        updateSelected['Average'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                    } else if (currentType == 'max') {
                        updateSelected['Max'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                    } else if (currentType == 'min') {
                        updateSelected['Min'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                    }
                    if (selected['Hourly Stats']) {
                        // 如果点击启用 Hourly Stats
                        currentStats = 'Hourly';
                        updateChart(); // 更新图表到 Hourly Stats
                    } else {
                        // 如果点击禁用 Hourly Stats
                        currentStats = 'Default';
                        resetChartToDefault(); // 重置图表到默认状态
                    }
                }

                function updateChart() {

                    // 创建表示每小时的标签数组
                    var dataHour = Array.from({ length: 24 }, (v, i) => `${i}:00`);

                    var errorData_1 = newData_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_1[index],
                        index: index
                    }));
                    var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_2[index],
                        index: index
                    }));

                    var errorData_3 = newData_gcc.map((value, index) => ({
                        value: value,
                        sd: sd_3[index],
                        index: index
                    }));
                    var errorData_4 = newData_gvi.map((value, index) => ({
                        value: value,
                        sd: sd_4[index],
                        index: index
                    }));
                    var errorData_5 = newData_rcc.map((value, index) => ({
                        value: value,
                        sd: sd_5[index],
                        index: index
                    }));
                    var errorData_6 = newData_bcc.map((value, index) => ({
                        value: value,
                        sd: sd_6[index],
                        index: index
                    }));
                    var errorData_7 = newData_low_lai.map((value, index) => ({
                        value: value,
                        sd: sd_7[index],
                        index: index
                    }));
                    var errorData_8 = newData_fvc.map((value, index) => ({
                        value: value,
                        sd: sd_8[index],
                        index: index
                    }));


                    function renderItem_1(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#CCFF66', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#CCFF66', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_2(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_3(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#498D4B', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#498D4B', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_4(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_5(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#94070A', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#94070A', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_6(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_7(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#A47D1C', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#A47D1C', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_8(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#FF5D5D', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }


                    if(currentType === 'average'){
                        // 更新图表的数据和图例选中状态
                        myChart.setOption({// backgroundColor: "#344b58",
                            "title": {
                                "text": "",
                                "subtext": '',
                                x: "4%",

                                textStyle: {
                                    color: '#fff',
                                    fontSize: '22'
                                },
                                subtextStyle: {
                                    color: '#90979c',
                                    fontSize: '16',

                                },
                            },
                            "tooltip": {
                                "trigger": "axis",
                                "axisPointer": {
                                    "type": "shadow",
                                    textStyle: {
                                        color: "#fff"
                                    }
                                },
                                formatter: function(params) {
                                    // console.log(params)
                                    var indexX =0;
                                    for(var x=0;x<xData_109.length;x++){
                                        if(params[0].name === xData_109[x]){
                                            indexX = x;
                                            break;
                                        }
                                    }

                                    var displayString = '监测时间：' + params[0].name
                                    for(var m =0;m<params.length;m++){
                                        var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                        displayString = displayString + itemString
                                    }
                                    return displayString
                                }
                            },
                            "grid": {
                                "borderWidth": 0,
                                "top": 110,
                                "bottom": 95,
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            "calculable": true,
                            "xAxis": [{
                                "type": "category",
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "splitLine": {
                                    "show": false
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "splitArea": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "data": dataHour,
                            }],
                            "yAxis": [{
                                "type": "value",
                                "splitLine": {
                                    "show": false
                                },
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "splitArea": {
                                    "show": false
                                },

                            }],
                            // "dataZoom": [{
                            //     "show": true,
                            //     "height": 30,
                            //     "xAxisIndex": [
                            //         0
                            //     ],
                            //     bottom: 30,
                            //     "start": 0,
                            //     "end": 100,
                            //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            //     handleSize: '110%',
                            //     handleStyle: {
                            //         color: "#d3dee5",

                            //     },
                            //     textStyle: {
                            //         color: "#fff"
                            //     },
                            //     borderColor: "#90979c"


                            // }, {
                            //     "type": "inside",
                            //     "show": true,
                            //     "height": 15,
                            //     "start": 1,
                            //     "end": 35
                            // }],
                            legend: [{
                                right: '4%',
                                top: '3%',  // 主图例，包含所有的指标
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                            },
                                {
                                    right: '4%',
                                    top: '8%', // 统计指标图例，稍微往下
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                    data: ["Average", "Max", "Min", "Hourly Stats"],
                                    selected: updateSelected,
                                }],
                            "series": [
                                // {
                                //     "name": "NDVI",
                                //     "type": "line",
                                //     // "stack": "总量",
                                //     symbol: 'circle',
                                //     "symbolSize": 8, // 设置节点大小
                                //     "lineStyle": {
                                //         "type": "dashed", // 设置为虚线
                                //         "opacity": 0.5, // 线条透明度
                                //     },
                                //     "itemStyle": {
                                //         "normal": {
                                //             "color": "#CCFF66",
                                //             "label": {
                                //                 "show": false,
                                //                 "textStyle": {
                                //                     "color": "#fff"
                                //                 },
                                //                 "position": "insideTop",
                                //                 formatter: function(p) {
                                //                     return p.value > 0 ? (p.value) : '';
                                //                 }
                                //             }
                                //         }
                                //     },
                                //     "data": _data_109_1,
                                //     seriesId: 'ndvi', // 关联ID
                                // },
                                // {
                                //     type: 'custom',
                                //     name: 'NDVI Standard Deviation',
                                //     renderItem: renderItem,
                                //     itemStyle: {
                                //         normal: {
                                //             color: '#FE0A0A'
                                //         }
                                //     },
                                //     encode: {
                                //         x: 0,
                                //         y: [1, 2]
                                //     },
                                //     data: errorData,
                                //     seriesId: 'ndvi', // 关联ID
                                //     z: 100,
                                // },
                                {
                                    name: 'NDVI',
                                    type: 'custom',
                                    renderItem: renderItem_1,
                                    data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#CCFF66",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'ROI NDVI',
                                    type: 'custom',
                                    renderItem: renderItem_2,
                                    data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(0,191,183,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'GCC',
                                    type: 'custom',
                                    renderItem: renderItem_3,
                                    data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#498D4B",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'GVI',
                                    type: 'custom',
                                    renderItem: renderItem_4,
                                    data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(186,85,211,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'RCC',
                                    type: 'custom',
                                    renderItem: renderItem_5,
                                    data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#94070A",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'BCC',
                                    type: 'custom',
                                    renderItem: renderItem_6,
                                    data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(252,230,48,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'LOW_LAI',
                                    type: 'custom',
                                    renderItem: renderItem_7,
                                    data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#A47D1C",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'FVC',
                                    type: 'custom',
                                    renderItem: renderItem_8,
                                    data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#FF5D5D",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                }]
                        });
                    }

                    if(currentType === 'max'||currentType === 'min'){
                        // 更新图表的数据和图例选中状态
                        myChart.setOption({// backgroundColor: "#344b58",
                            "title": {
                                "text": "",
                                "subtext": '',
                                x: "4%",

                                textStyle: {
                                    color: '#fff',
                                    fontSize: '22'
                                },
                                subtextStyle: {
                                    color: '#90979c',
                                    fontSize: '16',

                                },
                            },
                            "tooltip": {
                                "trigger": "axis",
                                "axisPointer": {
                                    "type": "shadow",
                                    textStyle: {
                                        color: "#fff"
                                    }
                                },
                                formatter: function(params) {
                                    // console.log(params)
                                    var indexX =0;
                                    for(var x=0;x<xData_109.length;x++){
                                        if(params[0].name === xData_109[x]){
                                            indexX = x;
                                            break;
                                        }
                                    }

                                    var displayString = '监测时间：' + params[0].name
                                    for(var m =0;m<params.length;m++){
                                        var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                        displayString = displayString + itemString
                                    }
                                    return displayString
                                }
                            },
                            "grid": {
                                "borderWidth": 0,
                                "top": 110,
                                "bottom": 95,
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            "calculable": true,
                            "xAxis": [{
                                "type": "category",
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "splitLine": {
                                    "show": false
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "splitArea": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "data": dataHour,
                            }],
                            "yAxis": [{
                                "type": "value",
                                "splitLine": {
                                    "show": false
                                },
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "splitArea": {
                                    "show": false
                                },

                            }],
                            // "dataZoom": [{
                            //     "show": true,
                            //     "height": 30,
                            //     "xAxisIndex": [
                            //         0
                            //     ],
                            //     bottom: 30,
                            //     "start": 0,
                            //     "end": 100,
                            //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            //     handleSize: '110%',
                            //     handleStyle: {
                            //         color: "#d3dee5",

                            //     },
                            //     textStyle: {
                            //         color: "#fff"
                            //     },
                            //     borderColor: "#90979c"


                            // }, {
                            //     "type": "inside",
                            //     "show": true,
                            //     "height": 15,
                            //     "start": 1,
                            //     "end": 35
                            // }],
                            legend: [{
                                right: '4%',
                                top: '3%',  // 主图例，包含所有的指标
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                            },
                                {
                                    right: '4%',
                                    top: '8%', // 统计指标图例，稍微往下
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                    data: ["Average", "Max", "Min", "Hourly Stats"],
                                    selected: updateSelected,
                                }],
                            "series": [
                                {
                                    "name": "NDVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#CCFF66",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_ndvi,
                                },
                                {
                                    "name": "ROI NDVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    // "barMaxWidth": 35,
                                    // "barGap": "10%",
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(0,191,183,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_roi_ndvi
                                },
                                {
                                    "name": "GCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#498D4B",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_gcc
                                },
                                {
                                    "name": "GVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(186,85,211,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":  newData_gvi
                                },
                                {
                                    "name": "RCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#94070A",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_rcc
                                },
                                {
                                    "name": "BCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    // symbolSize: 10,
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(252,230,48,1)",
                                            "barBorderRadius": 0,
                                            "label": {
                                                "show": false,
                                                "position": "top",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_bcc
                                },
                                {
                                    "name": "LOW_LAI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                        "lineDash": [5, 5], // Dashed line pattern
                                    },
                                    "barMaxWidth": 35,
                                    "barGap": "10%",
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#A47D1C",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_low_lai
                                },
                                {
                                    "name": "FVC",
                                    "type": "line",
                                    // "stack": "总量",
                                    // symbolSize: 10,
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#FF5D5D",
                                            "barBorderRadius": 0,
                                            "label": {
                                                "show": false,
                                                "position": "top",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_fvc
                                },
                            ]
                        });
                    }
                }

                function resetChartToDefault() {
                    // 实现重置图表到默认状态的逻辑
                    console.log("Resetting to default view");
                    if (currentType === 'average') {
                        newData_ndvi = averages_ndvi;
                        newData_roi_ndvi = averages_roi_ndvi;
                        newData_gcc = averages_gcc;
                        newData_gvi = averages_gvi;
                        newData_rcc = averages_rcc;
                        newData_bcc = averages_bcc;
                        newData_low_lai = averages_low_lai;
                        newData_fvc = averages_fvc;
                        updateSelected['Average'] = true;
                    } else if (currentType === 'max') {
                        newData_ndvi = maxValues_ndvi;
                        newData_roi_ndvi = maxValues_roi_ndvi;
                        newData_gcc = maxValues_gcc;
                        newData_gvi = maxValues_gvi;
                        newData_rcc = maxValues_rcc;
                        newData_bcc = maxValues_bcc;
                        newData_low_lai = maxValues_low_lai;
                        newData_fvc = maxValues_fvc;
                        updateSelected['Max'] = true;
                    } else if (currentType === 'min') {
                        newData_ndvi = minValues_ndvi;
                        newData_roi_ndvi= minValues_roi_ndvi;
                        newData_gcc = minValues_gcc;
                        newData_gvi = minValues_gvi;
                        newData_rcc = minValues_rcc;
                        newData_bcc = minValues_bcc;
                        newData_low_lai = minValues_low_lai;
                        newData_fvc = minValues_fvc;
                        updateSelected['Min'] = true;
                    }
                    var errorData_1 = newData_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_1[index],
                        index: index
                    }));
                    var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_2[index],
                        index: index
                    }));

                    var errorData_3 = newData_gcc.map((value, index) => ({
                        value: value,
                        sd: sd_3[index],
                        index: index
                    }));
                    var errorData_4 = newData_gvi.map((value, index) => ({
                        value: value,
                        sd: sd_4[index],
                        index: index
                    }));
                    var errorData_5 = newData_rcc.map((value, index) => ({
                        value: value,
                        sd: sd_5[index],
                        index: index
                    }));
                    var errorData_6 = newData_bcc.map((value, index) => ({
                        value: value,
                        sd: sd_6[index],
                        index: index
                    }));
                    var errorData_7 = newData_low_lai.map((value, index) => ({
                        value: value,
                        sd: sd_7[index],
                        index: index
                    }));
                    var errorData_8 = newData_fvc.map((value, index) => ({
                        value: value,
                        sd: sd_8[index],
                        index: index
                    }));


                    function renderItem_1(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#CCFF66', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#CCFF66', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_2(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_3(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#498D4B', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#498D4B', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_4(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_5(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#94070A', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#94070A', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_6(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_7(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#A47D1C', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#A47D1C', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    function renderItem_8(params, api) {
                        var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                        var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                        var sdValue = api.value(2); // 当天的标准差

                        // console.log(yValue)

                        var point = api.coord([xValue, yValue]);
                        var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                        var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                        var halfWidth = 5; // 小横线的一半宽度

                        var children = [
                            // 上标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdTop[1],
                                    x2: point[0] + halfWidth, y2: sdTop[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 垂直线连接上下标准差
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: sdTop[1],
                                    x2: point[0], y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 下标准差小横线
                            {
                                type: 'line',
                                shape: {
                                    x1: point[0] - halfWidth, y1: sdBottom[1],
                                    x2: point[0] + halfWidth, y2: sdBottom[1]
                                },
                                style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                            },
                            // 数据点
                            {
                                type: 'circle',
                                shape: {
                                    cx: point[0], cy: point[1], r: 5
                                },
                                style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                            }
                        ];

                        if (params.dataIndex < params.dataInsideLength - 1) {
                            var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                            children.push({
                                type: 'line',
                                shape: {
                                    x1: point[0], y1: point[1],
                                    x2: nextPoint[0], y2: nextPoint[1]
                                },
                                style: api.style({
                                    stroke: '#FF5D5D', // Color of the dashed line
                                    lineDash: [5, 5], // Dashed line pattern
                                    lineWidth: 2 // Ensuring the line is visible enough
                                })
                            });
                        }

                        return {
                            type: 'group',
                            children: children
                        };
                    }

                    // console.log(updateSelected);
                    // console.log(newData_roi_ndvi);

                    if(currentType === 'average'){
                        // 更新图表的数据和图例选中状态
                        myChart.setOption({// backgroundColor: "#344b58",
                            "title": {
                                "text": "",
                                "subtext": '',
                                x: "4%",

                                textStyle: {
                                    color: '#fff',
                                    fontSize: '22'
                                },
                                subtextStyle: {
                                    color: '#90979c',
                                    fontSize: '16',

                                },
                            },
                            "tooltip": {
                                "trigger": "axis",
                                "axisPointer": {
                                    "type": "shadow",
                                    textStyle: {
                                        color: "#fff"
                                    }
                                },
                                formatter: function(params) {
                                    // console.log(params)
                                    var indexX =0;
                                    for(var x=0;x<xData_109.length;x++){
                                        if(params[0].name === xData_109[x]){
                                            indexX = x;
                                            break;
                                        }
                                    }

                                    var displayString = '监测时间：' + params[0].name
                                    for(var m =0;m<params.length;m++){
                                        var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                        displayString = displayString + itemString
                                    }
                                    return displayString
                                }
                            },
                            "grid": {
                                "borderWidth": 0,
                                "top": 110,
                                "bottom": 95,
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            "calculable": true,
                            "xAxis": [{
                                "type": "category",
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "splitLine": {
                                    "show": false
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "splitArea": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "data": xData_109,
                            }],
                            "yAxis": [{
                                "type": "value",
                                "splitLine": {
                                    "show": false
                                },
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "splitArea": {
                                    "show": false
                                },

                            }],
                            // "dataZoom": [{
                            //     "show": true,
                            //     "height": 30,
                            //     "xAxisIndex": [
                            //         0
                            //     ],
                            //     bottom: 30,
                            //     "start": 0,
                            //     "end": 100,
                            //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            //     handleSize: '110%',
                            //     handleStyle: {
                            //         color: "#d3dee5",

                            //     },
                            //     textStyle: {
                            //         color: "#fff"
                            //     },
                            //     borderColor: "#90979c"


                            // }, {
                            //     "type": "inside",
                            //     "show": true,
                            //     "height": 15,
                            //     "start": 1,
                            //     "end": 35
                            // }],
                            legend: [{
                                right: '4%',
                                top: '3%',  // 主图例，包含所有的指标
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                            },
                                {
                                    right: '4%',
                                    top: '8%', // 统计指标图例，稍微往下
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                    data: ["Average", "Max", "Min", "Hourly Stats"],
                                    selected: updateSelected,
                                }],
                            "series": [
                                // {
                                //     "name": "NDVI",
                                //     "type": "line",
                                //     // "stack": "总量",
                                //     symbol: 'circle',
                                //     "symbolSize": 8, // 设置节点大小
                                //     "lineStyle": {
                                //         "type": "dashed", // 设置为虚线
                                //         "opacity": 0.5, // 线条透明度
                                //     },
                                //     "itemStyle": {
                                //         "normal": {
                                //             "color": "#CCFF66",
                                //             "label": {
                                //                 "show": false,
                                //                 "textStyle": {
                                //                     "color": "#fff"
                                //                 },
                                //                 "position": "insideTop",
                                //                 formatter: function(p) {
                                //                     return p.value > 0 ? (p.value) : '';
                                //                 }
                                //             }
                                //         }
                                //     },
                                //     "data": _data_109_1,
                                //     seriesId: 'ndvi', // 关联ID
                                // },
                                // {
                                //     type: 'custom',
                                //     name: 'NDVI Standard Deviation',
                                //     renderItem: renderItem,
                                //     itemStyle: {
                                //         normal: {
                                //             color: '#FE0A0A'
                                //         }
                                //     },
                                //     encode: {
                                //         x: 0,
                                //         y: [1, 2]
                                //     },
                                //     data: errorData,
                                //     seriesId: 'ndvi', // 关联ID
                                //     z: 100,
                                // },
                                {
                                    name: 'NDVI',
                                    type: 'custom',
                                    renderItem: renderItem_1,
                                    data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#CCFF66",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'ROI NDVI',
                                    type: 'custom',
                                    renderItem: renderItem_2,
                                    data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(0,191,183,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'GCC',
                                    type: 'custom',
                                    renderItem: renderItem_3,
                                    data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#498D4B",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'GVI',
                                    type: 'custom',
                                    renderItem: renderItem_4,
                                    data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(186,85,211,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'RCC',
                                    type: 'custom',
                                    renderItem: renderItem_5,
                                    data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#94070A",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'BCC',
                                    type: 'custom',
                                    renderItem: renderItem_6,
                                    data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(252,230,48,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'LOW_LAI',
                                    type: 'custom',
                                    renderItem: renderItem_7,
                                    data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#A47D1C",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                },
                                {
                                    name: 'FVC',
                                    type: 'custom',
                                    renderItem: renderItem_8,
                                    data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                                    encode: {
                                        x: 0,
                                        y: 1,
                                        tooltip: [1]
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#FF5D5D",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                }]
                        });
                    }

                    if(currentType === 'max'||currentType === 'min'){
                        // 更新图表的数据和图例选中状态
                        myChart.setOption({// backgroundColor: "#344b58",
                            "title": {
                                "text": "",
                                "subtext": '',
                                x: "4%",

                                textStyle: {
                                    color: '#fff',
                                    fontSize: '22'
                                },
                                subtextStyle: {
                                    color: '#90979c',
                                    fontSize: '16',

                                },
                            },
                            "tooltip": {
                                "trigger": "axis",
                                "axisPointer": {
                                    "type": "shadow",
                                    textStyle: {
                                        color: "#fff"
                                    }
                                },
                                formatter: function(params) {
                                    // console.log(params)
                                    var indexX =0;
                                    for(var x=0;x<xData_109.length;x++){
                                        if(params[0].name === xData_109[x]){
                                            indexX = x;
                                            break;
                                        }
                                    }

                                    var displayString = '监测时间：' + params[0].name
                                    for(var m =0;m<params.length;m++){
                                        var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                        displayString = displayString + itemString
                                    }
                                    return displayString
                                }
                            },
                            "grid": {
                                "borderWidth": 0,
                                "top": 110,
                                "bottom": 95,
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            "calculable": true,
                            "xAxis": [{
                                "type": "category",
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "splitLine": {
                                    "show": false
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "splitArea": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "data": xData_109,
                            }],
                            "yAxis": [{
                                "type": "value",
                                "splitLine": {
                                    "show": false
                                },
                                "axisLine": {
                                    lineStyle: {
                                        color: '#90979c'
                                    }
                                },
                                "axisTick": {
                                    "show": false
                                },
                                "axisLabel": {
                                    "interval": 0,
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                },
                                "splitArea": {
                                    "show": false
                                },

                            }],
                            // "dataZoom": [{
                            //     "show": true,
                            //     "height": 30,
                            //     "xAxisIndex": [
                            //         0
                            //     ],
                            //     bottom: 30,
                            //     "start": 0,
                            //     "end": 100,
                            //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                            //     handleSize: '110%',
                            //     handleStyle: {
                            //         color: "#d3dee5",

                            //     },
                            //     textStyle: {
                            //         color: "#fff"
                            //     },
                            //     borderColor: "#90979c"


                            // }, {
                            //     "type": "inside",
                            //     "show": true,
                            //     "height": 15,
                            //     "start": 1,
                            //     "end": 35
                            // }],
                            legend: [{
                                right: '4%',
                                top: '3%',  // 主图例，包含所有的指标
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                            },
                                {
                                    right: '4%',
                                    top: '8%', // 统计指标图例，稍微往下
                                    textStyle: {
                                        color: '#fff',
                                        fontSize: '16',
                                    },
                                    data: ["Average", "Max", "Min", "Hourly Stats"],
                                    selected: updateSelected,
                                }],
                            "series": [
                                {
                                    "name": "NDVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#CCFF66",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_ndvi,
                                },
                                {
                                    "name": "ROI NDVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    // "barMaxWidth": 35,
                                    // "barGap": "10%",
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(0,191,183,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_roi_ndvi
                                },
                                {
                                    "name": "GCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#498D4B",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_gcc
                                },
                                {
                                    "name": "GVI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(186,85,211,1)",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":  newData_gvi
                                },
                                {
                                    "name": "RCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#94070A",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_rcc
                                },
                                {
                                    "name": "BCC",
                                    "type": "line",
                                    // "stack": "总量",
                                    // symbolSize: 10,
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "rgba(252,230,48,1)",
                                            "barBorderRadius": 0,
                                            "label": {
                                                "show": false,
                                                "position": "top",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_bcc
                                },
                                {
                                    "name": "LOW_LAI",
                                    "type": "line",
                                    // "stack": "总量",
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                        "lineDash": [5, 5], // Dashed line pattern
                                    },
                                    "barMaxWidth": 35,
                                    "barGap": "10%",
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#A47D1C",
                                            "label": {
                                                "show": false,
                                                "textStyle": {
                                                    "color": "#fff"
                                                },
                                                "position": "insideTop",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data": newData_low_lai
                                },
                                {
                                    "name": "FVC",
                                    "type": "line",
                                    // "stack": "总量",
                                    // symbolSize: 10,
                                    symbol: 'circle',
                                    "symbolSize": 8, // 设置节点大小
                                    "lineStyle": {
                                        "type": "dashed", // 设置为虚线
                                        "opacity": 0.7, // 线条透明度
                                    },
                                    "itemStyle": {
                                        "normal": {
                                            "color": "#FF5D5D",
                                            "barBorderRadius": 0,
                                            "label": {
                                                "show": false,
                                                "position": "top",
                                                formatter: function(p) {
                                                    return p.value > 0 ? (p.value) : '';
                                                }
                                            }
                                        }
                                    },
                                    "data":newData_fvc
                                },
                            ]
                        });
                    }
                }

                // 强制更新所有图例的选中状态以匹配实际情况
                updateSelected[params.name] = params.selected[params.name];
                myChart.setOption({
                    legend: {
                        selected: updateSelected
                    }
                });

                var errorData_1 = newData_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_1[index],
                    index: index
                }));
                var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_2[index],
                    index: index
                }));

                var errorData_3 = newData_gcc.map((value, index) => ({
                    value: value,
                    sd: sd_3[index],
                    index: index
                }));
                var errorData_4 = newData_gvi.map((value, index) => ({
                    value: value,
                    sd: sd_4[index],
                    index: index
                }));
                var errorData_5 = newData_rcc.map((value, index) => ({
                    value: value,
                    sd: sd_5[index],
                    index: index
                }));
                var errorData_6 = newData_bcc.map((value, index) => ({
                    value: value,
                    sd: sd_6[index],
                    index: index
                }));
                var errorData_7 = newData_low_lai.map((value, index) => ({
                    value: value,
                    sd: sd_7[index],
                    index: index
                }));
                var errorData_8 = newData_fvc.map((value, index) => ({
                    value: value,
                    sd: sd_8[index],
                    index: index
                }));


                function renderItem_1(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#CCFF66', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#CCFF66', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_2(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_3(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#498D4B', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#498D4B', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_4(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_5(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#94070A', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#94070A', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_6(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_7(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#A47D1C', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#A47D1C', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_8(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#FF5D5D', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }


                if(params.name=='Average'){
                    if(currentStats === 'Hourly'){
                        // 如果当前是 Hourly Stats 模式

                        console.log("如果当前是 Hourly Stats 模式")

                        // 确保 Hourly Stats 依旧被选中
                        updateSelected['Hourly Stats'] = true;

                        // 将每个指标的数据更新为按小时统计的数据
                        if (currentType == 'average') {
                            updateSelected['Average'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                        } else if (currentType == 'max') {
                            updateSelected['Max'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                        } else if (currentType == 'min') {
                            updateSelected['Min'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                        }

                        datahour = Array.from({ length: 24 }, (v, i) => `${i}:00`);
                    }
                    var errorData_1 = newData_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_1[index],
                        index: index
                    }));
                    var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                        value: value,
                        sd: sd_2[index],
                        index: index
                    }));

                    var errorData_3 = newData_gcc.map((value, index) => ({
                        value: value,
                        sd: sd_3[index],
                        index: index
                    }));
                    var errorData_4 = newData_gvi.map((value, index) => ({
                        value: value,
                        sd: sd_4[index],
                        index: index
                    }));
                    var errorData_5 = newData_rcc.map((value, index) => ({
                        value: value,
                        sd: sd_5[index],
                        index: index
                    }));
                    var errorData_6 = newData_bcc.map((value, index) => ({
                        value: value,
                        sd: sd_6[index],
                        index: index
                    }));
                    var errorData_7 = newData_low_lai.map((value, index) => ({
                        value: value,
                        sd: sd_7[index],
                        index: index
                    }));
                    var errorData_8 = newData_fvc.map((value, index) => ({
                        value: value,
                        sd: sd_8[index],
                        index: index
                    }));
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": datahour,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        // "dataZoom": [{
                        //     "show": true,
                        //     "height": 30,
                        //     "xAxisIndex": [
                        //         0
                        //     ],
                        //     bottom: 30,
                        //     "start": 0,
                        //     "end": 100,
                        //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        //     handleSize: '110%',
                        //     handleStyle: {
                        //         color: "#d3dee5",

                        //     },
                        //     textStyle: {
                        //         color: "#fff"
                        //     },
                        //     borderColor: "#90979c"


                        // }, {
                        //     "type": "inside",
                        //     "show": true,
                        //     "height": 15,
                        //     "start": 1,
                        //     "end": 35
                        // }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            // {
                            //     "name": "NDVI",
                            //     "type": "line",
                            //     // "stack": "总量",
                            //     symbol: 'circle',
                            //     "symbolSize": 8, // 设置节点大小
                            //     "lineStyle": {
                            //         "type": "dashed", // 设置为虚线
                            //         "opacity": 0.5, // 线条透明度
                            //     },
                            //     "itemStyle": {
                            //         "normal": {
                            //             "color": "#CCFF66",
                            //             "label": {
                            //                 "show": false,
                            //                 "textStyle": {
                            //                     "color": "#fff"
                            //                 },
                            //                 "position": "insideTop",
                            //                 formatter: function(p) {
                            //                     return p.value > 0 ? (p.value) : '';
                            //                 }
                            //             }
                            //         }
                            //     },
                            //     "data": _data_109_1,
                            //     seriesId: 'ndvi', // 关联ID
                            // },
                            // {
                            //     type: 'custom',
                            //     name: 'NDVI Standard Deviation',
                            //     renderItem: renderItem,
                            //     itemStyle: {
                            //         normal: {
                            //             color: '#FE0A0A'
                            //         }
                            //     },
                            //     encode: {
                            //         x: 0,
                            //         y: [1, 2]
                            //     },
                            //     data: errorData,
                            //     seriesId: 'ndvi', // 关联ID
                            //     z: 100,
                            // },
                            {
                                name: 'NDVI',
                                type: 'custom',
                                renderItem: renderItem_1,
                                data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'ROI NDVI',
                                type: 'custom',
                                renderItem: renderItem_2,
                                data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GCC',
                                type: 'custom',
                                renderItem: renderItem_3,
                                data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GVI',
                                type: 'custom',
                                renderItem: renderItem_4,
                                data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'RCC',
                                type: 'custom',
                                renderItem: renderItem_5,
                                data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'BCC',
                                type: 'custom',
                                renderItem: renderItem_6,
                                data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'LOW_LAI',
                                type: 'custom',
                                renderItem: renderItem_7,
                                data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'FVC',
                                type: 'custom',
                                renderItem: renderItem_8,
                                data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            }]
                    });
                }

                if(params.name=='Max'||params.name=='Min'){

                    if(currentStats === 'Hourly'){
                        // 如果当前是 Hourly Stats 模式

                        console.log("如果当前是 Hourly Stats 模式")

                        // 确保 Hourly Stats 依旧被选中
                        updateSelected['Hourly Stats'] = true;

                        // 将每个指标的数据更新为按小时统计的数据
                        if (currentType == 'average') {
                            updateSelected['Average'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                        } else if (currentType == 'max') {
                            updateSelected['Max'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                        } else if (currentType == 'min') {
                            updateSelected['Min'] = true;
                            newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                            newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                            newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                            newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                            newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                            newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                            newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                            newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                        }

                        xData_109 = Array.from({ length: 24 }, (v, i) => `${i}:00`);

                    }
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": xData_109,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        // "dataZoom": [{
                        //     "show": true,
                        //     "height": 30,
                        //     "xAxisIndex": [
                        //         0
                        //     ],
                        //     bottom: 30,
                        //     "start": 0,
                        //     "end": 100,
                        //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        //     handleSize: '110%',
                        //     handleStyle: {
                        //         color: "#d3dee5",

                        //     },
                        //     textStyle: {
                        //         color: "#fff"
                        //     },
                        //     borderColor: "#90979c"


                        // }, {
                        //     "type": "inside",
                        //     "show": true,
                        //     "height": 15,
                        //     "start": 1,
                        //     "end": 35
                        // }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            {
                                "name": "NDVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_ndvi,
                            },
                            {
                                "name": "ROI NDVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                // "barMaxWidth": 35,
                                // "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_roi_ndvi
                            },
                            {
                                "name": "GCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_gcc
                            },
                            {
                                "name": "GVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":  newData_gvi
                            },
                            {
                                "name": "RCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_rcc
                            },
                            {
                                "name": "BCC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_bcc
                            },
                            {
                                "name": "LOW_LAI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                    "lineDash": [5, 5], // Dashed line pattern
                                },
                                "barMaxWidth": 35,
                                "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_low_lai
                            },
                            {
                                "name": "FVC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_fvc
                            },
                        ]
                    });
                }


            });
        }

        // 下面是时间选择器以外的逻辑，也就是默认的没有经过时间选择的正常的逻辑，和时间选择器的逻辑很像
        var labelInterval = Math.floor(xData_109.length / 5);
        var maxLabels = 5;
        var interval = Math.floor(xData_109.length / maxLabels);
        var labelIndexes = new Set();
        for (let i = 0; i < xData_109.length; i += interval) {
            labelIndexes.add(i);
        }
        var _data_109_1 = averages_ndvi;
        var _data_109_2 = averages_roi_ndvi;
        var _data_109_3 = averages_gcc;
        var _data_109_4 = averages_gvi;
        var _data_109_5 = averages_rcc;
        var _data_109_6 = averages_bcc;
        var _data_109_7 = averages_low_lai;
        var _data_109_8 = averages_fvc;

        // 计算单个数据点标准差的函数，这里的values应该是每天的所有数据点数组
        function calculateStandardDeviation(values) {
            let dailySDs = [];
            // 假设values是一个二维数组，每个子数组代表一天的所有数据点
            values.forEach(dayValues => {
                const mean = dayValues.reduce((a, b) => a + b, 0) / dayValues.length;
                const sd = Math.sqrt(dayValues.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / dayValues.length);
                dailySDs.push(sd);
            });
            return dailySDs;
        }

        var sd_1 = calculateStandardDeviation(raw_ndvi);
        var sd_2 = calculateStandardDeviation(raw_roi_ndvi);
        var sd_3 = calculateStandardDeviation(raw_gcc);
        var sd_4 = calculateStandardDeviation(raw_gvi);
        var sd_5 = calculateStandardDeviation(raw_rcc);
        var sd_6 = calculateStandardDeviation(raw_bcc);
        var sd_7 = calculateStandardDeviation(raw_low_lai);
        var sd_8 = calculateStandardDeviation(raw_fvc);

        var errorData_1 = _data_109_1.map((value, index) => ({
            value: value,
            //每天计算得到的标准差创建每个数据点的错误数据
            sd: sd_1[index],
            index: index
        }));
        var errorData_2 = _data_109_2.map((value, index) => ({
            value: value,
            sd: sd_2[index],
            index: index
        }));
        var errorData_3 = _data_109_3.map((value, index) => ({
            value: value,
            sd: sd_3[index],
            index: index
        }));
        var errorData_4 = _data_109_4.map((value, index) => ({
            value: value,
            sd: sd_4[index],
            index: index
        }));
        var errorData_5 = _data_109_5.map((value, index) => ({
            value: value,
            sd: sd_5[index],
            index: index
        }));
        var errorData_6 = _data_109_6.map((value, index) => ({
            value: value,
            sd: sd_6[index],
            index: index
        }));
        var errorData_7 = _data_109_7.map((value, index) => ({
            value: value,
            sd: sd_7[index],
            index: index
        }));
        var errorData_8 = _data_109_8.map((value, index) => ({
            value: value,
            sd: sd_8[index],
            index: index
        }));


        function renderItem_1(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: '#CCFF66', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: '#CCFF66', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }
        function renderItem_2(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }


        function renderItem_3(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: '#498D4B', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: '#498D4B', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }

        function renderItem_4(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }

        function renderItem_5(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: '#94070A', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: '#94070A', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }

        function renderItem_6(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }

        function renderItem_7(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: '#A47D1C', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: '#A47D1C', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }

        function renderItem_8(params, api) {
            var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
            var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
            var sdValue = api.value(2); // 当天的标准差

            // console.log(yValue)

            var point = api.coord([xValue, yValue]);
            var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
            var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

            var halfWidth = 5; // 小横线的一半宽度

            var children = [
                // 上标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdTop[1],
                        x2: point[0] + halfWidth, y2: sdTop[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 垂直线连接上下标准差
                {
                    type: 'line',
                    shape: {
                        x1: point[0], y1: sdTop[1],
                        x2: point[0], y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 下标准差小横线
                {
                    type: 'line',
                    shape: {
                        x1: point[0] - halfWidth, y1: sdBottom[1],
                        x2: point[0] + halfWidth, y2: sdBottom[1]
                    },
                    style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                },
                // 数据点
                {
                    type: 'circle',
                    shape: {
                        cx: point[0], cy: point[1], r: 5
                    },
                    style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                }
            ];

            if (params.dataIndex < params.dataInsideLength - 1) {
                var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                children.push({
                    type: 'line',
                    shape: {
                        x1: point[0], y1: point[1],
                        x2: nextPoint[0], y2: nextPoint[1]
                    },
                    style: api.style({
                        stroke: '#FF5D5D', // Color of the dashed line
                        lineDash: [5, 5], // Dashed line pattern
                        lineWidth: 2 // Ensuring the line is visible enough
                    })
                });
            }

            return {
                type: 'group',
                children: children
            };
        }


        option109 = {
            // backgroundColor: "#344b58",
            "title": {
                "text": "",
                "subtext": '',
                x: "4%",

                textStyle: {
                    color: '#fff',
                    fontSize: '22'
                },
                subtextStyle: {
                    color: '#90979c',
                    fontSize: '16',

                },
            },
            "tooltip": {
                "trigger": "axis",
                "axisPointer": {
                    "type": "shadow",
                    textStyle: {
                        color: "#fff"
                    }
                },
                formatter: function(params) {
                    // console.log(params)
                    var indexX =0;
                    for(var x=0;x<xData_109.length;x++){
                        if(params[0].name === xData_109[x]){
                            indexX = x;
                            break;
                        }
                    }

                    var displayString = '监测时间：' + params[0].name
                    for(var m =0;m<params.length;m++){
                        var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' +  "(index, value, sd)" + params[m].data;
                        displayString = displayString + itemString
                    }
                    return displayString
                }
            },
            "grid": {
                "borderWidth": 0,
                "top": 110,
                "bottom": 95,
                textStyle: {
                    color: "#fff"
                }
            },
            legend: [{
                right: '4%',
                top: '3%',  // 主图例，包含所有的指标
                textStyle: {
                    color: '#fff',
                    fontSize: '16',
                },
                data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
            },
                {
                    right: '4%',
                    top: '8%', // 统计指标图例，稍微往下
                    textStyle: {
                        color: '#fff',
                        fontSize: '16',
                    },
                    data: ["Average", "Max", "Min", "Hourly Stats"],
                    selected: {
                        "Average": true, // 默认选择平均值
                        "Max": false,
                        "Min": false,
                        "Hourly Stats": false
                    }
                }],


            "calculable": true,
            "xAxis": [{
                "type": "category",
                "axisLine": {
                    lineStyle: {
                        color: '#90979c'
                    }
                },
                "splitLine": {
                    "show": false
                },
                "axisTick": {
                    "show": false
                },
                "splitArea": {
                    "show": false
                },
                "axisLabel": {
                    "interval": 0,
                    textStyle: {
                        color: '#fff',
                        fontSize: '16',
                    },
                    formatter: function (value, index) {
                        // 只显示特定的索引标签
                        return labelIndexes.has(index) ? value : '';
                    }
                },
                "data": xData_109,
            }],
            "yAxis": [{
                "type": "value",
                "splitLine": {
                    "show": false
                },
                "axisLine": {
                    lineStyle: {
                        color: '#90979c'
                    }
                },
                "axisTick": {
                    "show": false
                },
                "axisLabel": {
                    "interval": labelInterval,
                    textStyle: {
                        color: '#fff',
                        fontSize: '16',
                    },
                },
                "splitArea": {
                    "show": false
                },

            }],
            // "dataZoom": [{
            //     "show": true,
            //     "height": 30,
            //     "xAxisIndex": [
            //         0
            //     ],
            //     bottom: 30,
            //     "start": 0,
            //     "end": 100,
            //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
            //     handleSize: '110%',
            //     handleStyle: {
            //         color: "#d3dee5",

            //     },
            //     textStyle: {
            //         color: "#fff"
            //     },
            //     borderColor: "#90979c"
            // },
            //  {
            //     "type": "inside",
            //     "show": true,
            //     "height": 15,
            //     "start": 1,
            //     "end": 35
            // }],
            "series": [
                // {
                //     "name": "NDVI",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "#CCFF66",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data": _data_109_1,
                //     seriesId: 'ndvi', // 关联ID
                // },
                // {
                //     type: 'custom',
                //     name: 'NDVI Standard Deviation',
                //     renderItem: renderItem,
                //     itemStyle: {
                //         normal: {
                //             color: '#FE0A0A'
                //         }
                //     },
                //     encode: {
                //         x: 0,
                //         y: [1, 2]
                //     },
                //     data: errorData,
                //     seriesId: 'ndvi', // 关联ID
                //     z: 100,
                // },
                {
                    name: 'NDVI',
                    type: 'custom',
                    renderItem: renderItem_1,
                    data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 'index',
                        y: ['value','sd'],
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "#CCFF66",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'ROI NDVI',
                    type: 'custom',
                    renderItem: renderItem_2,
                    data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "rgba(0,191,183,1)",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'GCC',
                    type: 'custom',
                    renderItem: renderItem_3,
                    data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "#498D4B",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'GVI',
                    type: 'custom',
                    renderItem: renderItem_4,
                    data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "rgba(186,85,211,1)",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'RCC',
                    type: 'custom',
                    renderItem: renderItem_5,
                    data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "#94070A",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'BCC',
                    type: 'custom',
                    renderItem: renderItem_6,
                    data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "rgba(252,230,48,1)",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'LOW_LAI',
                    type: 'custom',
                    renderItem: renderItem_7,
                    data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "#A47D1C",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                {
                    name: 'FVC',
                    type: 'custom',
                    renderItem: renderItem_8,
                    data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                    encode: {
                        x: 0,
                        y: 1,
                        tooltip: [1]
                    },
                    "itemStyle": {
                        "normal": {
                            "color": "#FF5D5D",
                            "label": {
                                "show": false,
                                "textStyle": {
                                    "color": "#fff"
                                },
                                "position": "insideTop",
                                formatter: function(p) {
                                    return p.value > 0 ? (p.value) : '';
                                }
                            }
                        }
                    },
                },
                // {
                //     "name": "ROI NDVI",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     // "barMaxWidth": 35,
                //     // "barGap": "10%",
                //     "itemStyle": {
                //         "normal": {
                //             "color": "rgba(0,191,183,1)",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data":_data_109_2
                // },
                // {
                //     "name": "GCC",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "#498D4B",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data": _data_109_3
                // },
                // {
                //     "name": "GVI",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "rgba(186,85,211,1)",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data":  _data_109_4
                // },
                // {
                //     "name": "RCC",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "#94070A",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data":_data_109_5
                // },
                // {
                //     "name": "BCC",
                //     "type": "line",
                //     // "stack": "总量",
                //     // symbolSize: 10,
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "rgba(252,230,48,1)",
                //             "barBorderRadius": 0,
                //             "label": {
                //                 "show": false,
                //                 "position": "top",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data": _data_109_6
                // },
                // {
                //     "name": "LOW_LAI",
                //     "type": "line",
                //     // "stack": "总量",
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "barMaxWidth": 35,
                //     "barGap": "10%",
                //     "itemStyle": {
                //         "normal": {
                //             "color": "#A47D1C",
                //             "label": {
                //                 "show": false,
                //                 "textStyle": {
                //                     "color": "#fff"
                //                 },
                //                 "position": "insideTop",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data": _data_109_7
                // },
                // {
                //     "name": "FVC",
                //     "type": "line",
                //     // "stack": "总量",
                //     // symbolSize: 10,
                //     symbol: 'circle',
                //     "symbolSize": 8, // 设置节点大小
                //     "lineStyle": {
                //         "type": "dashed", // 设置为虚线
                //         "opacity": 0.5, // 线条透明度
                //     },
                //     "itemStyle": {
                //         "normal": {
                //             "color": "#FF5D5D",
                //             "barBorderRadius": 0,
                //             "label": {
                //                 "show": false,
                //                 "position": "top",
                //                 formatter: function(p) {
                //                     return p.value > 0 ? (p.value) : '';
                //                 }
                //             }
                //         }
                //     },
                //     "data":_data_109_8
                // },
                {
                    name: 'Average',
                    type: 'line'
                },
                {
                    name: 'Max',
                    type: 'line'
                },
                {
                    name: 'Min',
                    type: 'line'
                },
                {
                    name: 'Hourly Stats',
                    type: 'line'
                }
            ]
        }

        myChart.setOption(option109);

        myChart.on('legendselectchanged', function (params) {

            var selected = params.selected;

            console.log("params_name",params.name);

            // console.log("averages_roi_ndvi")
            // console.log(averages_roi_ndvi)

            var newData_ndvi;
            var newData_roi_ndvi;
            var newData_gcc;
            var newData_gvi;
            var newData_rcc;
            var newData_bcc;
            var newData_low_lai;
            var newData_fvc;


            // 更新currentType基于所选择的Legend
            var updateSelected = {
                'Average': false,
                'Max': false,
                'Min': false,
                'Hourly Stats': false
            };

            if(params.name==='Average'||params.name==='Max'||params.name==='Min'||params.name==='Hourly Stats'){
                updateSelected[params.name] = true;  // 设置当前选中的图例为true，其他为false
                // selected[params.name] = true;
            }

            if (isFirstSelect && (params.name === 'Average' || params.name === 'Max' || params.name === 'Min' || params.name === 'Hourly Stats')) {
                selected[params.name] = true;
                isFirstSelect = false;  // 重置变量，确保只发生一次
            }

            console.log("selected",selected);
            console.log("ifselected",selected['Hourly Stats']);

            function processHourlyStats(dataTime, valueTime) {
                // 创建一个包含24个空数组的数组，每个数组对应一个小时
                let hourlyData = Array.from({ length: 24 }, () => []);

                // 遍历时间和值的数据，将值分配到正确的小时数组中
                for (let i = 0; i < dataTime.length; i++) {
                    let time = dataTime[i];
                    let value = valueTime[i];
                    let hour = parseInt(time.split(':')[0]); // 直接从时间字符串"HH:MM:SS"中分割并取小时部分
                    hourlyData[hour].push(value);
                }

                // 计算每个小时的统计数据
                let hourlyStats = hourlyData.map(hour => {
                    if (hour.length === 0) return { average: null, max: null, min: null };

                    let sum = hour.reduce((acc, val) => acc + val, 0);
                    let average = sum / hour.length;
                    let max = Math.max(...hour);
                    let min = Math.min(...hour);

                    return { average, max, min };
                });

                return hourlyStats;
            }

            // 现在使用上面定义的函数来处理每个指标
            let hourlyStats_ndvi = processHourlyStats(dataTime, ndvi_time);
            let hourlyStats_roi_ndvi = processHourlyStats(dataTime, roi_ndvi_time);
            let hourlyStats_gcc = processHourlyStats(dataTime, gcc_time);
            let hourlyStats_gvi = processHourlyStats(dataTime, gvi_time);
            let hourlyStats_rcc = processHourlyStats(dataTime, rcc_time);
            let hourlyStats_bcc = processHourlyStats(dataTime, bcc_time);
            let hourlyStats_low_lai = processHourlyStats(dataTime, low_lai_time);
            let hourlyStats_fvc = processHourlyStats(dataTime, fvc_time);


            if (params.name === 'Average') {
                currentType = 'average';
                newData_ndvi = averages_ndvi;
                newData_roi_ndvi = averages_roi_ndvi;
                newData_gcc = averages_gcc;
                newData_gvi = averages_gvi;
                newData_rcc = averages_rcc;
                newData_bcc = averages_bcc;
                newData_low_lai = averages_low_lai;
                newData_fvc = averages_fvc;
                updateSelected['Average'] = true;
            } else if (params.name === 'Max') {
                currentType = 'max';
                newData_ndvi = maxValues_ndvi;
                newData_roi_ndvi = maxValues_roi_ndvi;
                newData_gcc = maxValues_gcc;
                newData_gvi = maxValues_gvi;
                newData_rcc = maxValues_rcc;
                newData_bcc = maxValues_bcc;
                newData_low_lai = maxValues_low_lai;
                newData_fvc = maxValues_fvc;
                updateSelected['Max'] = true;
            } else if (params.name === 'Min') {
                currentType = 'min';
                newData_ndvi = minValues_ndvi;
                newData_roi_ndvi= minValues_roi_ndvi;
                newData_gcc = minValues_gcc;
                newData_gvi = minValues_gvi;
                newData_rcc = minValues_rcc;
                newData_bcc = minValues_bcc;
                newData_low_lai = minValues_low_lai;
                newData_fvc = minValues_fvc;
                updateSelected['Min'] = true;
            } else if (params.name === 'Hourly Stats'){

                // 将每个指标的数据更新为按小时统计的数据
                if (currentType === 'average') {
                    updateSelected['Average'] = true;
                    newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                    newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                    newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                    newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                    newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                    newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                    newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                    newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                } else if (currentType === 'max') {
                    updateSelected['Max'] = true;
                    newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                    newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                    newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                    newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                    newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                    newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                    newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                    newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                } else if (currentType === 'min') {
                    updateSelected['Min'] = true;
                    newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                    newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                    newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                    newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                    newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                    newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                    newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                    newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                }

                if (selected['Hourly Stats']) {
                    // 如果点击启用 Hourly Stats
                    currentStats = 'Hourly';
                    updateChart(); // 更新图表到 Hourly Stats
                } else {
                    // 如果点击禁用 Hourly Stats
                    currentStats = 'Default';
                    resetChartToDefault(); // 重置图表到默认状态
                }
            }

            function resetChartToDefault() {

                // 实现重置图表到默认状态的逻辑
                console.log("Resetting to default view");
                if (currentType === 'average') {
                    newData_ndvi = averages_ndvi;
                    newData_roi_ndvi = averages_roi_ndvi;
                    newData_gcc = averages_gcc;
                    newData_gvi = averages_gvi;
                    newData_rcc = averages_rcc;
                    newData_bcc = averages_bcc;
                    newData_low_lai = averages_low_lai;
                    newData_fvc = averages_fvc;
                    updateSelected['Average'] = true;
                } else if (currentType === 'max') {
                    newData_ndvi = maxValues_ndvi;
                    newData_roi_ndvi = maxValues_roi_ndvi;
                    newData_gcc = maxValues_gcc;
                    newData_gvi = maxValues_gvi;
                    newData_rcc = maxValues_rcc;
                    newData_bcc = maxValues_bcc;
                    newData_low_lai = maxValues_low_lai;
                    newData_fvc = maxValues_fvc;
                    updateSelected['Max'] = true;
                } else if (currentType === 'min') {
                    newData_ndvi = minValues_ndvi;
                    newData_roi_ndvi= minValues_roi_ndvi;
                    newData_gcc = minValues_gcc;
                    newData_gvi = minValues_gvi;
                    newData_rcc = minValues_rcc;
                    newData_bcc = minValues_bcc;
                    newData_low_lai = minValues_low_lai;
                    newData_fvc = minValues_fvc;
                    updateSelected['Min'] = true;
                }
                var errorData_1 = newData_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_1[index],
                    index: index
                }));
                var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_2[index],
                    index: index
                }));

                var errorData_3 = newData_gcc.map((value, index) => ({
                    value: value,
                    sd: sd_3[index],
                    index: index
                }));
                var errorData_4 = newData_gvi.map((value, index) => ({
                    value: value,
                    sd: sd_4[index],
                    index: index
                }));
                var errorData_5 = newData_rcc.map((value, index) => ({
                    value: value,
                    sd: sd_5[index],
                    index: index
                }));
                var errorData_6 = newData_bcc.map((value, index) => ({
                    value: value,
                    sd: sd_6[index],
                    index: index
                }));
                var errorData_7 = newData_low_lai.map((value, index) => ({
                    value: value,
                    sd: sd_7[index],
                    index: index
                }));
                var errorData_8 = newData_fvc.map((value, index) => ({
                    value: value,
                    sd: sd_8[index],
                    index: index
                }));


                function renderItem_1(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#CCFF66', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#CCFF66', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_2(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_3(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#498D4B', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#498D4B', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_4(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_5(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#94070A', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#94070A', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_6(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_7(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#A47D1C', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#A47D1C', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_8(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#FF5D5D', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                if(currentType === 'average'){
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": xData_109,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        // "dataZoom": [{
                        //     "show": true,
                        //     "height": 30,
                        //     "xAxisIndex": [
                        //         0
                        //     ],
                        //     bottom: 30,
                        //     "start": 0,
                        //     "end": 100,
                        //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        //     handleSize: '110%',
                        //     handleStyle: {
                        //         color: "#d3dee5",

                        //     },
                        //     textStyle: {
                        //         color: "#fff"
                        //     },
                        //     borderColor: "#90979c"


                        // }, {
                        //     "type": "inside",
                        //     "show": true,
                        //     "height": 15,
                        //     "start": 1,
                        //     "end": 35
                        // }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"],
                            selected: updateSelected,
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            // {
                            //     "name": "NDVI",
                            //     "type": "line",
                            //     // "stack": "总量",
                            //     symbol: 'circle',
                            //     "symbolSize": 8, // 设置节点大小
                            //     "lineStyle": {
                            //         "type": "dashed", // 设置为虚线
                            //         "opacity": 0.5, // 线条透明度
                            //     },
                            //     "itemStyle": {
                            //         "normal": {
                            //             "color": "#CCFF66",
                            //             "label": {
                            //                 "show": false,
                            //                 "textStyle": {
                            //                     "color": "#fff"
                            //                 },
                            //                 "position": "insideTop",
                            //                 formatter: function(p) {
                            //                     return p.value > 0 ? (p.value) : '';
                            //                 }
                            //             }
                            //         }
                            //     },
                            //     "data": _data_109_1,
                            //     seriesId: 'ndvi', // 关联ID
                            // },
                            // {
                            //     type: 'custom',
                            //     name: 'NDVI Standard Deviation',
                            //     renderItem: renderItem,
                            //     itemStyle: {
                            //         normal: {
                            //             color: '#FE0A0A'
                            //         }
                            //     },
                            //     encode: {
                            //         x: 0,
                            //         y: [1, 2]
                            //     },
                            //     data: errorData,
                            //     seriesId: 'ndvi', // 关联ID
                            //     z: 100,
                            // },
                            {
                                name: 'NDVI',
                                type: 'custom',
                                renderItem: renderItem_1,
                                data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'ROI NDVI',
                                type: 'custom',
                                renderItem: renderItem_2,
                                data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GCC',
                                type: 'custom',
                                renderItem: renderItem_3,
                                data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GVI',
                                type: 'custom',
                                renderItem: renderItem_4,
                                data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'RCC',
                                type: 'custom',
                                renderItem: renderItem_5,
                                data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'BCC',
                                type: 'custom',
                                renderItem: renderItem_6,
                                data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'LOW_LAI',
                                type: 'custom',
                                renderItem: renderItem_7,
                                data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'FVC',
                                type: 'custom',
                                renderItem: renderItem_8,
                                data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            }]
                    });
                }

                if(currentType === 'max'||currentType === 'min'){
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": xData_109,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        // "dataZoom": [{
                        //     "show": true,
                        //     "height": 30,
                        //     "xAxisIndex": [
                        //         0
                        //     ],
                        //     bottom: 30,
                        //     "start": 0,
                        //     "end": 100,
                        //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        //     handleSize: '110%',
                        //     handleStyle: {
                        //         color: "#d3dee5",

                        //     },
                        //     textStyle: {
                        //         color: "#fff"
                        //     },
                        //     borderColor: "#90979c"


                        // }, {
                        //     "type": "inside",
                        //     "show": true,
                        //     "height": 15,
                        //     "start": 1,
                        //     "end": 35
                        // }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"],
                            selected: updateSelected,
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            {
                                "name": "NDVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_ndvi,
                            },
                            {
                                "name": "ROI NDVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                // "barMaxWidth": 35,
                                // "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_roi_ndvi
                            },
                            {
                                "name": "GCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_gcc
                            },
                            {
                                "name": "GVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":  newData_gvi
                            },
                            {
                                "name": "RCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_rcc
                            },
                            {
                                "name": "BCC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_bcc
                            },
                            {
                                "name": "LOW_LAI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                    "lineDash": [5, 5], // Dashed line pattern
                                },
                                "barMaxWidth": 35,
                                "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_low_lai
                            },
                            {
                                "name": "FVC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_fvc
                            },
                        ]
                    });
                }

                //强制更新所有图例的选中状态以匹配实际情况
                updateSelected[params.name] = params.selected[params.name];
                myChart.setOption({
                    legend: {
                        selected: updateSelected
                    }
                });

                console.log("我是reset的更新legend状态",updateSelected);

                // 强制重绘图表
                myChart.resize();

            }


            var errorData_1 = newData_ndvi.map((value, index) => ({
                value: value,
                sd: sd_1[index],
                index: index
            }));
            var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                value: value,
                sd: sd_2[index],
                index: index
            }));

            var errorData_3 = newData_gcc.map((value, index) => ({
                value: value,
                sd: sd_3[index],
                index: index
            }));
            var errorData_4 = newData_gvi.map((value, index) => ({
                value: value,
                sd: sd_4[index],
                index: index
            }));
            var errorData_5 = newData_rcc.map((value, index) => ({
                value: value,
                sd: sd_5[index],
                index: index
            }));
            var errorData_6 = newData_bcc.map((value, index) => ({
                value: value,
                sd: sd_6[index],
                index: index
            }));
            var errorData_7 = newData_low_lai.map((value, index) => ({
                value: value,
                sd: sd_7[index],
                index: index
            }));
            var errorData_8 = newData_fvc.map((value, index) => ({
                value: value,
                sd: sd_8[index],
                index: index
            }));


            function renderItem_1(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#CCFF66', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#CCFF66', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_2(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_3(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#498D4B', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#498D4B', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_4(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_5(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#94070A', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#94070A', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_6(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_7(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#A47D1C', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#A47D1C', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            function renderItem_8(params, api) {
                var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                var sdValue = api.value(2); // 当天的标准差

                // console.log(yValue)

                var point = api.coord([xValue, yValue]);
                var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                var halfWidth = 5; // 小横线的一半宽度

                var children = [
                    // 上标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdTop[1],
                            x2: point[0] + halfWidth, y2: sdTop[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 垂直线连接上下标准差
                    {
                        type: 'line',
                        shape: {
                            x1: point[0], y1: sdTop[1],
                            x2: point[0], y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 下标准差小横线
                    {
                        type: 'line',
                        shape: {
                            x1: point[0] - halfWidth, y1: sdBottom[1],
                            x2: point[0] + halfWidth, y2: sdBottom[1]
                        },
                        style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                    },
                    // 数据点
                    {
                        type: 'circle',
                        shape: {
                            cx: point[0], cy: point[1], r: 5
                        },
                        style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                    }
                ];

                if (params.dataIndex < params.dataInsideLength - 1) {
                    var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                    children.push({
                        type: 'line',
                        shape: {
                            x1: point[0], y1: point[1],
                            x2: nextPoint[0], y2: nextPoint[1]
                        },
                        style: api.style({
                            stroke: '#FF5D5D', // Color of the dashed line
                            lineDash: [5, 5], // Dashed line pattern
                            lineWidth: 2 // Ensuring the line is visible enough
                        })
                    });
                }

                return {
                    type: 'group',
                    children: children
                };
            }

            if(params.name==='Average'){
                if(currentStats === 'Hourly'){
                    // 如果当前是 Hourly Stats 模式

                    console.log("如果当前是 Hourly Stats 模式")

                    // 确保 Hourly Stats 依旧被选中
                    updateSelected['Hourly Stats'] = true;

                    // 将每个指标的数据更新为按小时统计的数据
                    if (currentType == 'average') {
                        updateSelected['Average'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                    } else if (currentType == 'max') {
                        updateSelected['Max'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                    } else if (currentType == 'min') {
                        updateSelected['Min'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                    }

                    xData_109 = Array.from({ length: 24 }, (v, i) => `${i}:00`);
                }
                var errorData_1 = newData_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_1[index],
                    index: index
                }));
                var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_2[index],
                    index: index
                }));

                var errorData_3 = newData_gcc.map((value, index) => ({
                    value: value,
                    sd: sd_3[index],
                    index: index
                }));
                var errorData_4 = newData_gvi.map((value, index) => ({
                    value: value,
                    sd: sd_4[index],
                    index: index
                }));
                var errorData_5 = newData_rcc.map((value, index) => ({
                    value: value,
                    sd: sd_5[index],
                    index: index
                }));
                var errorData_6 = newData_bcc.map((value, index) => ({
                    value: value,
                    sd: sd_6[index],
                    index: index
                }));
                var errorData_7 = newData_low_lai.map((value, index) => ({
                    value: value,
                    sd: sd_7[index],
                    index: index
                }));
                var errorData_8 = newData_fvc.map((value, index) => ({
                    value: value,
                    sd: sd_8[index],
                    index: index
                }));
                // 更新图表的数据和图例选中状态
                myChart.setOption({// backgroundColor: "#344b58",
                    "title": {
                        "text": "",
                        "subtext": '',
                        x: "4%",

                        textStyle: {
                            color: '#fff',
                            fontSize: '22'
                        },
                        subtextStyle: {
                            color: '#90979c',
                            fontSize: '16',

                        },
                    },
                    "tooltip": {
                        "trigger": "axis",
                        "axisPointer": {
                            "type": "shadow",
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        formatter: function(params) {
                            // console.log(params)
                            var indexX =0;
                            for(var x=0;x<xData_109.length;x++){
                                if(params[0].name === xData_109[x]){
                                    indexX = x;
                                    break;
                                }
                            }

                            var displayString = '监测时间：' + params[0].name
                            for(var m =0;m<params.length;m++){
                                var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                displayString = displayString + itemString
                            }
                            return displayString
                        }
                    },
                    "grid": {
                        "borderWidth": 0,
                        "top": 110,
                        "bottom": 95,
                        textStyle: {
                            color: "#fff"
                        }
                    },
                    "calculable": true,
                    "xAxis": [{
                        "type": "category",
                        "axisLine": {
                            lineStyle: {
                                color: '#90979c'
                            }
                        },
                        "splitLine": {
                            "show": false
                        },
                        "axisTick": {
                            "show": false
                        },
                        "splitArea": {
                            "show": false
                        },
                        "axisLabel": {
                            "interval": 0,
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                        },
                        "data": xData_109,
                    }],
                    "yAxis": [{
                        "type": "value",
                        "splitLine": {
                            "show": false
                        },
                        "axisLine": {
                            lineStyle: {
                                color: '#90979c'
                            }
                        },
                        "axisTick": {
                            "show": false
                        },
                        "axisLabel": {
                            "interval": 0,
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                        },
                        "splitArea": {
                            "show": false
                        },

                    }],
                    // "dataZoom": [{
                    //     "show": true,
                    //     "height": 30,
                    //     "xAxisIndex": [
                    //         0
                    //     ],
                    //     bottom: 30,
                    //     "start": 0,
                    //     "end": 100,
                    //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                    //     handleSize: '110%',
                    //     handleStyle: {
                    //         color: "#d3dee5",

                    //     },
                    //     textStyle: {
                    //         color: "#fff"
                    //     },
                    //     borderColor: "#90979c"


                    // }, {
                    //     "type": "inside",
                    //     "show": true,
                    //     "height": 15,
                    //     "start": 1,
                    //     "end": 35
                    // }],
                    legend: [{
                        right: '4%',
                        top: '3%',  // 主图例，包含所有的指标
                        textStyle: {
                            color: '#fff',
                            fontSize: '16',
                        },
                        data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                    },
                        {
                            right: '4%',
                            top: '8%', // 统计指标图例，稍微往下
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["Average", "Max", "Min", "Hourly Stats"],
                            selected: updateSelected,
                        }],
                    "series": [
                        // {
                        //     "name": "NDVI",
                        //     "type": "line",
                        //     // "stack": "总量",
                        //     symbol: 'circle',
                        //     "symbolSize": 8, // 设置节点大小
                        //     "lineStyle": {
                        //         "type": "dashed", // 设置为虚线
                        //         "opacity": 0.5, // 线条透明度
                        //     },
                        //     "itemStyle": {
                        //         "normal": {
                        //             "color": "#CCFF66",
                        //             "label": {
                        //                 "show": false,
                        //                 "textStyle": {
                        //                     "color": "#fff"
                        //                 },
                        //                 "position": "insideTop",
                        //                 formatter: function(p) {
                        //                     return p.value > 0 ? (p.value) : '';
                        //                 }
                        //             }
                        //         }
                        //     },
                        //     "data": _data_109_1,
                        //     seriesId: 'ndvi', // 关联ID
                        // },
                        // {
                        //     type: 'custom',
                        //     name: 'NDVI Standard Deviation',
                        //     renderItem: renderItem,
                        //     itemStyle: {
                        //         normal: {
                        //             color: '#FE0A0A'
                        //         }
                        //     },
                        //     encode: {
                        //         x: 0,
                        //         y: [1, 2]
                        //     },
                        //     data: errorData,
                        //     seriesId: 'ndvi', // 关联ID
                        //     z: 100,
                        // },
                        {
                            name: 'NDVI',
                            type: 'custom',
                            renderItem: renderItem_1,
                            data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#CCFF66",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'ROI NDVI',
                            type: 'custom',
                            renderItem: renderItem_2,
                            data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(0,191,183,1)",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'GCC',
                            type: 'custom',
                            renderItem: renderItem_3,
                            data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#498D4B",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'GVI',
                            type: 'custom',
                            renderItem: renderItem_4,
                            data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(186,85,211,1)",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'RCC',
                            type: 'custom',
                            renderItem: renderItem_5,
                            data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#94070A",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'BCC',
                            type: 'custom',
                            renderItem: renderItem_6,
                            data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(252,230,48,1)",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'LOW_LAI',
                            type: 'custom',
                            renderItem: renderItem_7,
                            data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#A47D1C",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        },
                        {
                            name: 'FVC',
                            type: 'custom',
                            renderItem: renderItem_8,
                            data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                            encode: {
                                x: 0,
                                y: 1,
                                tooltip: [1]
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#FF5D5D",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                        }]
                });
            }

            if(params.name==='Max'||params.name==='Min'){

                if(currentStats === 'Hourly'){
                    // 如果当前是 Hourly Stats 模式

                    console.log("如果当前是 Hourly Stats 模式")

                    // 确保 Hourly Stats 依旧被选中
                    updateSelected['Hourly Stats'] = true;

                    // 将每个指标的数据更新为按小时统计的数据
                    if (currentType == 'average') {
                        updateSelected['Average'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.average);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.average);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.average);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.average);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.average);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.average);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.average);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.average);
                    } else if (currentType == 'max') {
                        updateSelected['Max'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.max);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.max);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.max);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.max);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.max);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.max);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.max);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.max);
                    } else if (currentType == 'min') {
                        updateSelected['Min'] = true;
                        newData_ndvi = hourlyStats_ndvi.map(stat => stat.min);
                        newData_roi_ndvi = hourlyStats_roi_ndvi.map(stat => stat.min);
                        newData_gcc = hourlyStats_gcc.map(stat => stat.min);
                        newData_gvi = hourlyStats_gvi.map(stat => stat.min);
                        newData_rcc = hourlyStats_rcc.map(stat => stat.min);
                        newData_bcc = hourlyStats_bcc.map(stat => stat.min);
                        newData_low_lai = hourlyStats_low_lai.map(stat => stat.min);
                        newData_fvc = hourlyStats_fvc.map(stat => stat.min);
                    }

                    xData_109 = Array.from({ length: 24 }, (v, i) => `${i}:00`);

                }
                // 更新图表的数据和图例选中状态
                myChart.setOption({// backgroundColor: "#344b58",
                    "title": {
                        "text": "",
                        "subtext": '',
                        x: "4%",

                        textStyle: {
                            color: '#fff',
                            fontSize: '22'
                        },
                        subtextStyle: {
                            color: '#90979c',
                            fontSize: '16',

                        },
                    },
                    "tooltip": {
                        "trigger": "axis",
                        "axisPointer": {
                            "type": "shadow",
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        formatter: function(params) {
                            // console.log(params)
                            var indexX =0;
                            for(var x=0;x<xData_109.length;x++){
                                if(params[0].name === xData_109[x]){
                                    indexX = x;
                                    break;
                                }
                            }

                            var displayString = '监测时间：' + params[0].name
                            for(var m =0;m<params.length;m++){
                                var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                displayString = displayString + itemString
                            }
                            return displayString
                        }
                    },
                    "grid": {
                        "borderWidth": 0,
                        "top": 110,
                        "bottom": 95,
                        textStyle: {
                            color: "#fff"
                        }
                    },
                    "calculable": true,
                    "xAxis": [{
                        "type": "category",
                        "axisLine": {
                            lineStyle: {
                                color: '#90979c'
                            }
                        },
                        "splitLine": {
                            "show": false
                        },
                        "axisTick": {
                            "show": false
                        },
                        "splitArea": {
                            "show": false
                        },
                        "axisLabel": {
                            "interval": 0,
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                        },
                        "data": xData_109,
                    }],
                    "yAxis": [{
                        "type": "value",
                        "splitLine": {
                            "show": false
                        },
                        "axisLine": {
                            lineStyle: {
                                color: '#90979c'
                            }
                        },
                        "axisTick": {
                            "show": false
                        },
                        "axisLabel": {
                            "interval": 0,
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                        },
                        "splitArea": {
                            "show": false
                        },

                    }],
                    // "dataZoom": [{
                    //     "show": true,
                    //     "height": 30,
                    //     "xAxisIndex": [
                    //         0
                    //     ],
                    //     bottom: 30,
                    //     "start": 0,
                    //     "end": 100,
                    //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                    //     handleSize: '110%',
                    //     handleStyle: {
                    //         color: "#d3dee5",

                    //     },
                    //     textStyle: {
                    //         color: "#fff"
                    //     },
                    //     borderColor: "#90979c"


                    // }, {
                    //     "type": "inside",
                    //     "show": true,
                    //     "height": 15,
                    //     "start": 1,
                    //     "end": 35
                    // }],
                    legend: [{
                        right: '4%',
                        top: '3%',  // 主图例，包含所有的指标
                        textStyle: {
                            color: '#fff',
                            fontSize: '16',
                        },
                        data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                    },
                        {
                            right: '4%',
                            top: '8%', // 统计指标图例，稍微往下
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["Average", "Max", "Min", "Hourly Stats"],
                            selected: updateSelected,
                        }],
                    "series": [
                        {
                            "name": "NDVI",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#CCFF66",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data": newData_ndvi,
                        },
                        {
                            "name": "ROI NDVI",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            // "barMaxWidth": 35,
                            // "barGap": "10%",
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(0,191,183,1)",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data":newData_roi_ndvi
                        },
                        {
                            "name": "GCC",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#498D4B",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data": newData_gcc
                        },
                        {
                            "name": "GVI",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(186,85,211,1)",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data":  newData_gvi
                        },
                        {
                            "name": "RCC",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#94070A",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data":newData_rcc
                        },
                        {
                            "name": "BCC",
                            "type": "line",
                            // "stack": "总量",
                            // symbolSize: 10,
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "rgba(252,230,48,1)",
                                    "barBorderRadius": 0,
                                    "label": {
                                        "show": false,
                                        "position": "top",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data": newData_bcc
                        },
                        {
                            "name": "LOW_LAI",
                            "type": "line",
                            // "stack": "总量",
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                                "lineDash": [5, 5], // Dashed line pattern
                            },
                            "barMaxWidth": 35,
                            "barGap": "10%",
                            "itemStyle": {
                                "normal": {
                                    "color": "#A47D1C",
                                    "label": {
                                        "show": false,
                                        "textStyle": {
                                            "color": "#fff"
                                        },
                                        "position": "insideTop",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data": newData_low_lai
                        },
                        {
                            "name": "FVC",
                            "type": "line",
                            // "stack": "总量",
                            // symbolSize: 10,
                            symbol: 'circle',
                            "symbolSize": 8, // 设置节点大小
                            "lineStyle": {
                                "type": "dashed", // 设置为虚线
                                "opacity": 0.7, // 线条透明度
                            },
                            "itemStyle": {
                                "normal": {
                                    "color": "#FF5D5D",
                                    "barBorderRadius": 0,
                                    "label": {
                                        "show": false,
                                        "position": "top",
                                        formatter: function(p) {
                                            return p.value > 0 ? (p.value) : '';
                                        }
                                    }
                                }
                            },
                            "data":newData_fvc
                        },
                    ]
                });
            }

            // console.log("检查processedDataTime是否能够传到此位置",processedDataTime)

            function updateChart() {
                // 输出统计数据和新数据数组以检查其正确性
                console.log('Hourly Stats NDVI:', hourlyStats_ndvi);
                console.log('New Data NDVI:', newData_ndvi);

                // 创建表示每小时的标签数组
                var dataHour = Array.from({ length: 24 }, (v, i) => `${i}:00`);

                var errorData_1 = newData_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_1[index],
                    index: index
                }));
                var errorData_2 = newData_roi_ndvi.map((value, index) => ({
                    value: value,
                    sd: sd_2[index],
                    index: index
                }));

                var errorData_3 = newData_gcc.map((value, index) => ({
                    value: value,
                    sd: sd_3[index],
                    index: index
                }));
                var errorData_4 = newData_gvi.map((value, index) => ({
                    value: value,
                    sd: sd_4[index],
                    index: index
                }));
                var errorData_5 = newData_rcc.map((value, index) => ({
                    value: value,
                    sd: sd_5[index],
                    index: index
                }));
                var errorData_6 = newData_bcc.map((value, index) => ({
                    value: value,
                    sd: sd_6[index],
                    index: index
                }));
                var errorData_7 = newData_low_lai.map((value, index) => ({
                    value: value,
                    sd: sd_7[index],
                    index: index
                }));
                var errorData_8 = newData_fvc.map((value, index) => ({
                    value: value,
                    sd: sd_8[index],
                    index: index
                }));


                function renderItem_1(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#CCFF66', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#CCFF66', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_2(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(0,191,183,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(0,191,183,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_3(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#498D4B', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#498D4B', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_4(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(186,85,211,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(186,85,211,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_5(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#94070A', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#94070A', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_6(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: 'rgba(252,230,48,1)', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: 'rgba(252,230,48,1)', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_7(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#A47D1C', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#A47D1C', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                function renderItem_8(params, api) {
                    var xValue = params.dataIndex; // 通过 dataIndex 获取当前点的索引
                    var yValue = api.value(1); // 真实的数值，就是平均值而不是数组数据
                    var sdValue = api.value(2); // 当天的标准差

                    // console.log(yValue)

                    var point = api.coord([xValue, yValue]);
                    var sdTop = api.coord([xValue, yValue + sdValue]); // 上标准差
                    var sdBottom = api.coord([xValue, yValue - sdValue]); // 下标准差

                    var halfWidth = 5; // 小横线的一半宽度

                    var children = [
                        // 上标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdTop[1],
                                x2: point[0] + halfWidth, y2: sdTop[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 垂直线连接上下标准差
                        {
                            type: 'line',
                            shape: {
                                x1: point[0], y1: sdTop[1],
                                x2: point[0], y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 下标准差小横线
                        {
                            type: 'line',
                            shape: {
                                x1: point[0] - halfWidth, y1: sdBottom[1],
                                x2: point[0] + halfWidth, y2: sdBottom[1]
                            },
                            style: api.style({ stroke: '#FE7A7A', lineWidth: 1 })
                        },
                        // 数据点
                        {
                            type: 'circle',
                            shape: {
                                cx: point[0], cy: point[1], r: 5
                            },
                            style: api.style({ fill: '#FF5D5D', stroke: 'none' })
                        }
                    ];

                    if (params.dataIndex < params.dataInsideLength - 1) {
                        var nextPoint = api.coord([api.value(0, params.dataIndex + 1), api.value(1, params.dataIndex + 1)]);
                        children.push({
                            type: 'line',
                            shape: {
                                x1: point[0], y1: point[1],
                                x2: nextPoint[0], y2: nextPoint[1]
                            },
                            style: api.style({
                                stroke: '#FF5D5D', // Color of the dashed line
                                lineDash: [5, 5], // Dashed line pattern
                                lineWidth: 2 // Ensuring the line is visible enough
                            })
                        });
                    }

                    return {
                        type: 'group',
                        children: children
                    };
                }

                // console.log(updateSelected);
                // console.log(newData_roi_ndvi);

                if(currentType === 'average'){
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(index, value, sd)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": dataHour,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        // "dataZoom": [{
                        //     "show": true,
                        //     "height": 30,
                        //     "xAxisIndex": [
                        //         0
                        //     ],
                        //     bottom: 30,
                        //     "start": 0,
                        //     "end": 100,
                        //     handleIcon: 'path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z',
                        //     handleSize: '110%',
                        //     handleStyle: {
                        //         color: "#d3dee5",

                        //     },
                        //     textStyle: {
                        //         color: "#fff"
                        //     },
                        //     borderColor: "#90979c"


                        // }, {
                        //     "type": "inside",
                        //     "show": true,
                        //     "height": 15,
                        //     "start": 1,
                        //     "end": 35
                        // }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            {
                                name: 'NDVI',
                                type: 'custom',
                                renderItem: renderItem_1,
                                data: errorData_1.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'ROI NDVI',
                                type: 'custom',
                                renderItem: renderItem_2,
                                data: errorData_2.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GCC',
                                type: 'custom',
                                renderItem: renderItem_3,
                                data: errorData_3.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'GVI',
                                type: 'custom',
                                renderItem: renderItem_4,
                                data: errorData_4.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'RCC',
                                type: 'custom',
                                renderItem: renderItem_5,
                                data: errorData_5.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'BCC',
                                type: 'custom',
                                renderItem: renderItem_6,
                                data: errorData_6.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'LOW_LAI',
                                type: 'custom',
                                renderItem: renderItem_7,
                                data: errorData_7.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            },
                            {
                                name: 'FVC',
                                type: 'custom',
                                renderItem: renderItem_8,
                                data: errorData_8.map((item) => [item.index, item.value, item.sd]),
                                encode: {
                                    x: 0,
                                    y: 1,
                                    tooltip: [1]
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                            }]
                    });
                }

                if(currentType === 'max'||currentType === 'min'){
                    // 更新图表的数据和图例选中状态
                    myChart.setOption({// backgroundColor: "#344b58",
                        "title": {
                            "text": "",
                            "subtext": '',
                            x: "4%",

                            textStyle: {
                                color: '#fff',
                                fontSize: '22'
                            },
                            subtextStyle: {
                                color: '#90979c',
                                fontSize: '16',

                            },
                        },
                        "tooltip": {
                            "trigger": "axis",
                            "axisPointer": {
                                "type": "shadow",
                                textStyle: {
                                    color: "#fff"
                                }
                            },
                            formatter: function(params) {
                                // console.log(params)
                                var indexX =0;
                                for(var x=0;x<xData_109.length;x++){
                                    if(params[0].name === xData_109[x]){
                                        indexX = x;
                                        break;
                                    }
                                }

                                var displayString = '监测时间：' + params[0].name
                                for(var m =0;m<params.length;m++){
                                    var itemString = '<br/>'+ params[m].marker + params[m].seriesName + '：' + "(value)" + params[m].data;
                                    displayString = displayString + itemString
                                }
                                return displayString
                            }
                        },
                        "grid": {
                            "borderWidth": 0,
                            "top": 110,
                            "bottom": 95,
                            textStyle: {
                                color: "#fff"
                            }
                        },
                        "calculable": true,
                        "xAxis": [{
                            "type": "category",
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "splitLine": {
                                "show": false
                            },
                            "axisTick": {
                                "show": false
                            },
                            "splitArea": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "data": dataHour,
                        }],
                        "yAxis": [{
                            "type": "value",
                            "splitLine": {
                                "show": false
                            },
                            "axisLine": {
                                lineStyle: {
                                    color: '#90979c'
                                }
                            },
                            "axisTick": {
                                "show": false
                            },
                            "axisLabel": {
                                "interval": 0,
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                            },
                            "splitArea": {
                                "show": false
                            },

                        }],
                        legend: [{
                            right: '4%',
                            top: '3%',  // 主图例，包含所有的指标
                            textStyle: {
                                color: '#fff',
                                fontSize: '16',
                            },
                            data: ["NDVI", "ROI NDVI", "GCC", "GVI", "RCC", "BCC", "LOW_LAI", "FVC"]
                        },
                            {
                                right: '4%',
                                top: '8%', // 统计指标图例，稍微往下
                                textStyle: {
                                    color: '#fff',
                                    fontSize: '16',
                                },
                                data: ["Average", "Max", "Min", "Hourly Stats"],
                                selected: updateSelected,
                            }],
                        "series": [
                            {
                                "name": "NDVI",
                                "type": "line",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#CCFF66",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_ndvi,
                            },
                            {
                                "name": "ROI NDVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                // "barMaxWidth": 35,
                                // "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(0,191,183,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_roi_ndvi
                            },
                            {
                                "name": "GCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#498D4B",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_gcc
                            },
                            {
                                "name": "GVI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(186,85,211,1)",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":  newData_gvi
                            },
                            {
                                "name": "RCC",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#94070A",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_rcc
                            },
                            {
                                "name": "BCC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "rgba(252,230,48,1)",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_bcc
                            },
                            {
                                "name": "LOW_LAI",
                                "type": "line",
                                // "stack": "总量",
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                    "lineDash": [5, 5], // Dashed line pattern
                                },
                                "barMaxWidth": 35,
                                "barGap": "10%",
                                "itemStyle": {
                                    "normal": {
                                        "color": "#A47D1C",
                                        "label": {
                                            "show": false,
                                            "textStyle": {
                                                "color": "#fff"
                                            },
                                            "position": "insideTop",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data": newData_low_lai
                            },
                            {
                                "name": "FVC",
                                "type": "line",
                                // "stack": "总量",
                                // symbolSize: 10,
                                symbol: 'circle',
                                "symbolSize": 8, // 设置节点大小
                                "lineStyle": {
                                    "type": "dashed", // 设置为虚线
                                    "opacity": 0.7, // 线条透明度
                                },
                                "itemStyle": {
                                    "normal": {
                                        "color": "#FF5D5D",
                                        "barBorderRadius": 0,
                                        "label": {
                                            "show": false,
                                            "position": "top",
                                            formatter: function(p) {
                                                return p.value > 0 ? (p.value) : '';
                                            }
                                        }
                                    }
                                },
                                "data":newData_fvc
                            },
                        ]
                    });
                }
            }

            // 强制更新所有图例的选中状态以匹配实际情况
            updateSelected[params.name] = params.selected[params.name];
            myChart.setOption({
                legend: {
                    selected: updateSelected
                }
            });


        });
    }

    //下面是静态加载.csv文件的逻辑，一共两部分：processData是正常日期Default模式下的数据；processDataTime是Hourly Stats模式下所用到的数据。
    //在加载完之后，会及时调用echart_12函数并将加载后的数据传入到图表中以供使用
    let processedData = [];
    let processedDataTime = [];

    function processData(data) {

        if (data.length > 0) {
            data.pop(); // 移除数组的最后一个元素
        }

        let groupedData = {};
        let fields = Object.keys(data[0]).filter(key => key !== 'time');

        data.forEach(item => {
            if (!item.time) {
                console.error('Missing time field', item);
                return; // 跳过没有时间字段的数据项
            }
            const dateTime = new Date(item.time); // 创建日期对象
            const date = dateTime.toLocaleDateString('en-CA'); // 格式化日期为 YYYY-MM-DD 格

            if (!groupedData[date]) {
                groupedData[date] = {};
                fields.forEach(field => groupedData[date][field] = []);
            }
            fields.forEach(field => {
                if (item[field] !== undefined && !isNaN(parseFloat(item[field]))) {
                    groupedData[date][field].push(parseFloat(item[field]));
                }
            });
        });

        let stats = Object.keys(groupedData).map(date => {
            let dayStats = { date };
            fields.forEach(field => {
                const values = groupedData[date][field];
                dayStats[field] = {
                    average: values.reduce((a, b) => a + b, 0) / values.length,
                    max: Math.max(...values),
                    min: Math.min(...values),
                    values: values // 存储每日的具体值数组
                };
            });
            return dayStats;
        });

        return stats.sort((a, b) => new Date(a.date) - new Date(b.date));
    }

    // 每5分钟请求数据并处理
    function fetchAndProcessData() {
        fetch('http://localhost:8088/phenology-data')
            .then(response => response.json())
            .then(data => {
                processedData = processData(data);
                console.log("processedData",processedData);
                echart_12(processedData); // 更新图表
            })
            .catch(error => console.error('Error fetching phenology data:', error));
    }

    setInterval(fetchAndProcessData, 300000); // 设置定时器，每5分钟执行一次
    fetchAndProcessData(); // 初始调用一次以加载数据

    // 类似地，处理含时间的数据统计
    function processDataWithTime(data) {
        if (data.length > 0) {
            data.pop(); // 移除数组的最后一个元素
        }

        let groupedData = {};
        let fields = Object.keys(data[0]).filter(key => key !== 'time');

        data.forEach(item => {
            if (!item.time) {
                console.error('Missing time field', item);
                return; // 跳过没有时间字段的数据项
            }
            const dateTime = new Date(item.time); // 创建日期对象
            const date = dateTime.toLocaleDateString('en-CA'); // 日期部分
            const time = dateTime.toLocaleTimeString('en-US', { hour12: false }); // 时间部分


            if (!groupedData[date]) {
                groupedData[date] = {};
            }

            if (!groupedData[date][time]) {
                groupedData[date][time] = {};
                fields.forEach(field => groupedData[date][time][field] = []);
            }

            fields.forEach(field => {
                if (item[field] !== undefined && !isNaN(parseFloat(item[field]))) {
                    groupedData[date][time][field].push(parseFloat(item[field]));
                }
            });
        });

        let stats = [];
        Object.keys(groupedData).forEach(date => {
            Object.keys(groupedData[date]).forEach(time => {
                let timeStats = { date, time };
                fields.forEach(field => {
                    const values = groupedData[date][time][field];
                    timeStats[field] = {
                        average: values.reduce((a, b) => a + b, 0) / values.length,
                        max: Math.max(...values),
                        min: Math.min(...values),
                        values: values // 存储每个具体时间点的值数组
                    };
                });
                stats.push(timeStats);
            });
        });

        return stats.sort((a, b) => new Date(`${a.date} ${a.time}`) - new Date(`${b.date} ${b.time}`));
    }

    // 初始化和定期更新
    setInterval(() => {
        fetchAndProcessDataWithTime('http://localhost:8088/phenology-data'); // 传入API路径
    }, 300000); // 每5分钟更新
    fetchAndProcessDataWithTime('http://localhost:8088/phenology-data'); // 初始加载

    // 动态更新数据
    function fetchAndProcessDataWithTime(apiUrl) {
        fetch(apiUrl)
            .then(response => response.json())
            .then(data => {
                processedDataTime = processDataWithTime(data);
                console.log("processedDataTime",processedDataTime);
                echart_12(processedDataTime); // 更新图表
            })
            .catch(error => console.error('Error fetching time-based phenology data:', error));
    }

//     let processedData = [];
//     let processedDataTime = [];
//
//     // 定义从服务器获取数据并处理的函数
//     function fetchPhenologyData() {
//         fetch('http://localhost:8088/phenology-data')  // 确保这个URL与后端提供的API路径匹配
//             .then(response => response.json())
//             .then(data => {
//                 // 处理获取到的数据
//                 processedData = processData(data);
//                 processedDataTime = processDataWithTime(data);
//                 echart_12(processedData);  // 调用绘图函数，并传入处理后的数据
//             })
//             .catch(error => console.error('Error fetching phenology data:', error));
//     }
//
// // 每5分钟调用一次fetchPhenologyData
//     setInterval(fetchPhenologyData, 300000); // 300000 毫秒即 5 分钟
//
// // 初始加载数据
//     fetchPhenologyData();
//
//     //CSV文件的解析逻辑一去除
//     // function parseAndProcessCSV(url) {
//     //     Papa.parse(url, {
//     //         download: true,
//     //         header: true,
//     //         dynamicTyping: true,
//     //         complete: function(results) {
//     //             // console.log(results.data)
//     //             processedData = processData(results.data);
//     //             // console.log("怎么老调不好")
//     //             // console.log(processedData);
//     //             echart_12(processedData); // 调用绘图函数，并传入处理后的数据
//     //         }
//     //     });
//     // }
//     function processData(data) {
//
//         if (data.length > 0) {
//             data.pop(); // 移除数组的最后一个元素
//         }
//
//         let groupedData = {};
//         let fields = Object.keys(data[0]).filter(key => key !== 'time');
//
//         data.forEach(item => {
//             if (!item.time) {
//                 console.error('Missing time field', item);
//                 return; // 跳过没有时间字段的数据项
//             }
//             const date = item.time.split(' ')[0]; // 取日期部分
//             if (!groupedData[date]) {
//                 groupedData[date] = {};
//                 fields.forEach(field => groupedData[date][field] = []);
//             }
//             fields.forEach(field => {
//                 if (item[field] !== undefined && !isNaN(parseFloat(item[field]))) {
//                     groupedData[date][field].push(parseFloat(item[field]));
//                 }
//             });
//         });
//
//         let stats = Object.keys(groupedData).map(date => {
//             let dayStats = { date };
//             fields.forEach(field => {
//                 const values = groupedData[date][field];
//                 dayStats[field] = {
//                     average: values.reduce((a, b) => a + b, 0) / values.length,
//                     max: Math.max(...values),
//                     min: Math.min(...values),
//                     values: values // 存储每日的具体值数组
//                 };
//             });
//             return dayStats;
//         });
//
//         return stats.sort((a, b) => new Date(a.date) - new Date(b.date));
//     }
//     //CSV文件的解析逻辑二去除
//     // function parseAndProcessCSVWithTime(url) {
//     //     Papa.parse(url, {
//     //         download: true,
//     //         header: true,
//     //         dynamicTyping: true,
//     //         complete: function(results) {
//     //             processedDataTime = processDataWithTime(results.data);
//     //             // 调用绘图函数，并传入处理后的数据。这个不管原函数有没有形参表，都要传入，否则无法识别这种全局变量。
//     //             echart_12(processedDataTime);
//     //         }
//     //     });
//     // }
//     function processDataWithTime(data) {
//         if (data.length > 0) {
//             data.pop(); // 移除数组的最后一个元素
//         }
//         let groupedData = {};
//         let fields = Object.keys(data[0]).filter(key => key !== 'time');
//         data.forEach(item => {
//             if (!item.time) {
//                 console.error('Missing time field', item);
//                 return; // 跳过没有时间字段的数据项
//             }
//             const dateTime = item.time; // 保留完整的日期和时间
//             const date = dateTime.split(' ')[0]; // 日期部分
//             const time = dateTime.split(' ')[1]; // 时间部分
//             if (!groupedData[date]) {
//                 groupedData[date] = {};
//             }
//             if (!groupedData[date][time]) {
//                 groupedData[date][time] = {};
//                 fields.forEach(field => groupedData[date][time][field] = []);
//             }
//             fields.forEach(field => {
//                 if (item[field] !== undefined && !isNaN(parseFloat(item[field]))) {
//                     groupedData[date][time][field].push(parseFloat(item[field]));
//                 }
//             });
//         });
//         let stats = [];
//         Object.keys(groupedData).forEach(date => {
//             Object.keys(groupedData[date]).forEach(time => {
//                 let timeStats = { date, time };
//                 fields.forEach(field => {
//                     const values = groupedData[date][time][field];
//                     timeStats[field] = {
//                         average: values.reduce((a, b) => a + b, 0) / values.length,
//                         max: Math.max(...values),
//                         min: Math.min(...values),
//                         values: values // 存储每个具体时间点的值数组
//                     };
//                 });
//                 stats.push(timeStats);
//             });
//         });
//         return stats.sort((a, b) => new Date(`${a.date} ${a.time}`) - new Date(`${b.date} ${b.time}`));
//     }
    // 调用这个函数并传入CSV文件的路径
    // parseAndProcessCSV('/PhotoNet_3330_20240607000000_20240701095200.csv');
    // parseAndProcessCSVWithTime('/PhotoNet_3330_20240607000000_20240701095200.csv');

    // 下面的逻辑也同样重要：fetchData用于前端向后端请求数据，这里是我都数据的请求
    function fetchData() {
        fetch('http://localhost:8088/getdata')
            .then(response => response.json())
            .then(data => {
                console.log('Received data:', data);
                // 更新指标数据
                document.getElementById('latitude').querySelector('p').innerText = data.latitude.toFixed(6);
                document.getElementById('longitude').querySelector('p').innerText = data.longitude.toFixed(6);
                document.getElementById('ux').querySelector('p').innerText = data.Ux.toFixed(2);
                document.getElementById('uy').querySelector('p').innerText = data.Uy.toFixed(2);
                document.getElementById('co2_density').querySelector('p').innerText = data.CO2_density.toFixed(2);
                document.getElementById('h2o_density').querySelector('p').innerText = data.H2O_density.toFixed(2);
                document.getElementById('t_panel').querySelector('p').innerText = data.T_panel.toFixed(2);
                document.getElementById('batt_volt').querySelector('p').innerText = data.batt_volt.toFixed(2);
            })
            .catch(error => console.error('Error fetching data:', error));
    }

// 每5秒钟获取一次数据并更新页面
    setInterval(fetchData, 5000);

// 初始加载数据
//     fetchData();


    //echart_13 实时监控数据（涡度数据）
    function echart_13() {
        var chartDom = document.getElementById('chart_13');
        var myChart = echarts.init(chartDom);

        var option = {
            graphic: [
                {
                    type: 'text',
                    left: 'center',
                    top: '10%',
                    style: {
                        text: 'Loading time...',
                        fill: '#ffffff',
                        font: '24px Arial'
                    },
                    z: 100
                }
            ],
            series: [
                // Latitude
                {
                    type: 'gauge',
                    center: ['15%', '40%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: {
                        fontSize: 12,
                        fontWeight: 'bold'
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: -90,
                    max: 90,
                    data: [{value: 0, name: 'Latitude'}]
                },
                // Longitude
                {
                    type: 'gauge',
                    center: ['39%', '40%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: {
                        fontSize: 12,
                        fontWeight: 'bold'
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: -180,
                    max: 180,
                    data: [{value: 0, name: 'Longitude'}]
                },
                // Ux
                {
                    type: 'gauge',
                    center: ['63%', '40%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: {
                        fontSize: 12,
                        fontWeight: 'bold'
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: -10,
                    max: 10,
                    data: [{value: 0, name: 'Ux'}]
                },
                // Uy
                {
                    type: 'gauge',
                    center: ['87%', '40%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: {
                        fontSize: 12,
                        fontWeight: 'bold'
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: -10,
                    max: 10,
                    data: [{value: 0, name: 'Uy'}]
                },
                // CO2 Density
                {
                    type: 'gauge',
                    center: ['15%', '75%'],  // Position of the gauge
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: { // Customizing the axis labels
                        fontSize: 12, // Increased font size
                        fontWeight: 'bold' // Bold font weight
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: 0,
                    max: 1000,
                    data: [{value: 0, name: 'CO2 Density'}]
                },
                // H2O Density
                {
                    type: 'gauge',
                    center: ['39%', '75%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: { // Customizing the axis labels
                        fontSize: 12, // Increased font size
                        fontWeight: 'bold' // Bold font weight
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: 0,
                    max: 100,
                    data: [{value: 0, name: 'H2O Density'}]
                },
                // Panel Temperature
                {
                    type: 'gauge',
                    center: ['63%', '75%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: { // Customizing the axis labels
                        fontSize: 12, // Increased font size
                        fontWeight: 'bold' // Bold font weight
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: -50,
                    max: 50,
                    data: [{value: 0, name: 'Panel Temperature'}]
                },
                // Battery Voltage
                {
                    type: 'gauge',
                    center: ['87%', '75%'],
                    radius: '30%',
                    axisLine: { lineStyle: { width: 25 } },
                    axisLabel: { // Customizing the axis labels
                        fontSize: 12, // Increased font size
                        fontWeight: 'bold' // Bold font weight
                    },
                    title: {               // 标题样式
                        fontSize: 18,       // 字体大小减半
                        fontWeight: 'bold', // 字体加粗
                        color: '#FFFFFF'   // 字体颜色为白色
                    },
                    detail: {
                        fontSize: 20,
                        color: '#FFFFFF',
                        fontWeight: 'bold',
                        formatter: '{value}'
                    },
                    min: 0,
                    max: 24,
                    data: [{value: 0, name: 'Battery Voltage'}]
                }
            ]
        };

        myChart.setOption(option);

        function updateTime() {
            var now = new Date();
            var formattedTime = now.toLocaleString(); // 默认包括日期和时间
            myChart.setOption({
                graphic: [{
                    type: 'text',
                    left: 'center',
                    top: '10%',
                    style: {
                        text: 'Current Time: ' + formattedTime,
                        fill: '#ffffff',
                        font: '24px Arial'
                    }
                }]
            });
        }

        setInterval(updateTime, 1000); // Update time every second

        function fetchData() {
            fetch('http://localhost:8088/getdata')
                .then(response => response.json())
                .then(data => {
                    myChart.setOption({
                        series: [
                            {data: [{value: data.latitude, name: 'Latitude'}]},
                            {data: [{value: data.longitude, name: 'Longitude'}]},
                            {data: [{value: data.Ux, name: 'Ux'}]},
                            {data: [{value: data.Uy, name: 'Uy'}]},
                            {data: [{value: data.CO2_density, name: 'CO2 Density'}]},
                            {data: [{value: data.H2O_density, name: 'H2O Density'}]},
                            {data: [{value: data.T_panel, name: 'Panel Temperature'}]},
                            {data: [{value: data.batt_volt, name: 'Battery Voltage'}]}
                        ]
                    });
                })
                .catch(error => console.error('Error fetching data:', error));
        }

        setInterval(fetchData, 5000);
        fetchData();
    }

    //echart_14 暂时没有用
    function echart_14(){
        var myChart = echarts.init(document.getElementById('chart_14'));
        var option = {
            title: {
                text: '',
            },
        };
        myChart.setOption(option);
    }

    //操作按钮，也就是点击后左边栏的按钮，每个按钮更新两部分，同时调用所管理的echart图表
    $('.t_btn0').click(function () {
        $('.center_text').css('display', 'none');
        $('.t_cos0').css('display', 'block');
        echart_map();
    });
    $('.t_btn1').click(function () {
        $('.center_text').css('display', 'none');
        $('.t_cos1').css('display', 'block');
        echart_2();
    });
    $('.t_btn2').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos2').css('display', 'block');
        echart_0();
    });
    $('.t_btn3').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos3').css('display', 'block');
        echart_4();
    });
    $('.t_btn4').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos6').css('display', 'block');
        echart_6();
    });
    $('.t_btn5').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos4').css('display', 'block');
        echart_1();
    });
    $('.t_btn6').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos5').css('display', 'block');
        echart_3();
    });
    $('.t_btn7').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos5').css('display', 'block');
        echart_3();
    });
    $('.t_btn8').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos8').css('display', 'block');
        echart_8();
    });
    $('.t_btn9').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos9').css('display', 'block');
        echart_9();
    });
    $('.t_btn10').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos10').css('display', 'block');
        echart_10();
    });
    $('.t_btn11').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos11').css('display', 'block');
        echart_11();
    });
    $('.t_btn12').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos12').css('display', 'block');
        echart_12();
    });
    $('.t_btn13').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos13').css('display', 'block');
        echart_13();
    });
    $('.t_btn14').click(function(){
        $('.center_text').css('display', 'none');
        $('.t_cos14').css('display', 'block');
        echart_14();
    });
    //获取地址栏参数
    $(function(){
        function getUrlParms(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
                if(r!=null)
                return unescape(r[2]);
                return null;
            }
            var id = getUrlParms("id");
            if(id == 2){
                $('.center_text').css('display', 'none');
                $('.t_cos10').css('display', 'block');
                echart_10();
            }
            if(id == 3){
                $('.center_text').css('display', 'none');
                $('.t_cos11').css('display', 'block');
                echart_11();
            }
            if(id == 4){
                $('.center_text').css('display', 'none');
                $('.t_cos1').css('display', 'block');
                echart_2();
            }
            if(id == 5){
                $('.center_text').css('display', 'none');
                $('.t_cos6').css('display', 'block');
                echart_6();
            }
            if(id == 6){
                $('.center_text').css('display', 'none');
                $('.t_cos3').css('display', 'block');
                echart_4();
            }
            if(id == 7){
                $('.center_text').css('display', 'none');
                $('.t_cos5').css('display', 'block');
                echart_3();
            }
            if(id == 8){
                $('.center_text').css('display', 'none');
                $('.t_cos12').css('display', 'block');
                echart_12();
            }
            if(id == 9){
                $('.center_text').css('display', 'none');
                $('.t_cos13').css('display', 'block');
                echart_13();
            }
    });
});
